Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Onboarding backend #624

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
2 changes: 1 addition & 1 deletion backend/courses/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class CourseAdmin(admin.ModelAdmin):
readonly_fields = ("topic", "crosslistings", "course_attributes")
exclude = ("attributes",)
list_filter = ("semester",)
list_display = ("full_code", "semester", "title")
list_display = ("id", "full_code", "semester", "title")

list_select_related = ("department",)

Expand Down
2 changes: 1 addition & 1 deletion backend/courses/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1322,7 +1322,7 @@ def satisfying_courses(self):
| Q(id__in=self.courses.all())
)
)


"""
3rd-Party API
Expand Down
15 changes: 14 additions & 1 deletion backend/degree/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
PDPBetaUser,
Rule,
SatisfactionStatus,
DegreeProfile,
CourseTaken,
UserProfile
)


Expand Down Expand Up @@ -59,7 +62,14 @@ def get_urls(self):

def degree_editor(self, request):
context = dict(self.admin_site.each_context(request))
return TemplateResponse(request, "degree-editor.html", context)


class UserProfileAdmin(admin.ModelAdmin):
list_display = ("id", "user")


class DegreeProfileAdmin(admin.ModelAdmin):
list_display = ("id", "user_profile", "graduation_date")


admin.site.register(Rule, RuleAdmin)
Expand All @@ -69,3 +79,6 @@ def degree_editor(self, request):
admin.site.register(Fulfillment, FulfillmentAdmin)
admin.site.register(DoubleCountRestriction, DoubleCountRestrictionAdmin)
admin.site.register(Degree, DegreeAdmin)
admin.site.register(DegreeProfile, DegreeProfileAdmin)
admin.site.register(UserProfile, UserProfileAdmin)
admin.site.register(CourseTaken)
2 changes: 1 addition & 1 deletion backend/degree/management/commands/fetch_degrees.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from courses.util import get_current_semester
from degree.management.commands.deduplicate_rules import deduplicate_rules
from degree.models import Degree, program_code_to_name
from degree.models import Degree, program_code_to_name, add_course,
from degree.utils.degreeworks_client import DegreeworksClient
from degree.utils.parse_degreeworks import parse_and_save_degreeworks

Expand Down
58 changes: 58 additions & 0 deletions backend/degree/migrations/0008_auto_20240324_1246.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Generated by Django 3.2.24 on 2024-03-24 16:46

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('courses', '0066_course_credits'),
('degree', '0007_alter_dockedcourse_full_code'),
]

operations = [
migrations.CreateModel(
name='CourseTaken',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('semester', models.CharField(help_text='\nThe semester taken, in the form YYYYx\n', max_length=5)),
('grade', models.CharField(help_text="\nThe user's grade for this course\n", max_length=2)),
('course', models.ForeignKey(help_text='\nA list of course codes that the user has already taken, matched with semester\n', on_delete=django.db.models.deletion.CASCADE, to='courses.course')),
],
),
migrations.AlterField(
model_name='degree',
name='program',
field=models.CharField(choices=[('EU_BSE', 'Engineering BSE'), ('EU_BAS', 'Engineering BAS'), ('AU_BA', 'College BA'), ('WU_BS', 'Wharton BS'), ('NU_BSN', 'Nursing BSN')], help_text='\nThe program code for this degree, e.g., EU_BSE\n', max_length=10),
),
migrations.CreateModel(
name='Transcript',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('program', models.CharField(db_index=True, help_text="\nThe user's current program (e.g. SEAS B.S.)\n", max_length=255)),
('courses', models.ForeignKey(blank=True, help_text='\nCourses already taken, prob a list of Course objects\n', null=True, on_delete=django.db.models.deletion.SET_NULL, to='courses.course')),
],
),
migrations.CreateModel(
name='DegreeProfile',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('graduation_date', models.CharField(help_text="\nThe user's expected graduation date (of the form YYYYx where x is A [for spring],\nB [summer], or C [fall]), e.g. `2019C` for fall 2019)\n", max_length=5)),
('courses_taken', models.ManyToManyField(help_text='\nA list of course codes that the user has already taken, matched with semester\n', related_name='degree_profiles', through='degree.CourseTaken', to='courses.Course')),
('degrees', models.ManyToManyField(help_text="\nThe user's current degree(s)\n", to='degree.Degree')),
('transcript', models.OneToOneField(help_text="The user's uploaded transcript parsed into a Transcript object (optional)", null=True, on_delete=django.db.models.deletion.CASCADE, related_name='degree_profile', to='degree.transcript')),
('transfer_credits', models.ManyToManyField(help_text='\nTransfer credits\n', related_name='transfer_credit_profiles', to='courses.Course')),
('user_profile', models.OneToOneField(help_text='extending the user profile class from courses to store degree plan specific info', on_delete=django.db.models.deletion.CASCADE, related_name='degree_profile', to='courses.userprofile')),
],
),
migrations.AddField(
model_name='coursetaken',
name='degree_profile',
field=models.ForeignKey(help_text='\nThe degree profile belonging to the user that took this course\n', on_delete=django.db.models.deletion.CASCADE, to='degree.degreeprofile'),
),
migrations.AddConstraint(
model_name='coursetaken',
constraint=models.UniqueConstraint(fields=('degree_profile', 'course', 'semester'), name='unique_course_taken'),
),
]
38 changes: 38 additions & 0 deletions backend/degree/migrations/0009_auto_20240324_1730.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Generated by Django 3.2.24 on 2024-03-24 21:30
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: it's a good idea to merge these migrations into one (you can just roll back to the migration before the ones you added using python manage.py migrate XXXX where XXXX is the last migration not in this PR. You can then delete all the migrations created in this PR and run python manage.py makemigration


from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('courses', '0066_course_credits'),
('degree', '0008_auto_20240324_1246'),
]

operations = [
migrations.RemoveConstraint(
model_name='coursetaken',
name='unique_course_taken',
),
migrations.AlterField(
model_name='coursetaken',
name='degree_profile',
field=models.ForeignKey(help_text='\nThe degree profile to which this course was taken\n', on_delete=django.db.models.deletion.CASCADE, to='degree.degreeprofile'),
),
migrations.AlterField(
model_name='degreeprofile',
name='courses_taken',
field=models.ManyToManyField(help_text='\nA list of course codes that the user has already taken, matched with semester\n', related_name='degree_profile', through='degree.CourseTaken', to='courses.Course'),
),
migrations.AlterField(
model_name='degreeprofile',
name='transfer_credits',
field=models.ManyToManyField(help_text='\nTransfer credits\n', related_name='transfer_credits_for', to='courses.Course'),
),
migrations.AddConstraint(
model_name='coursetaken',
constraint=models.UniqueConstraint(fields=('degree_profile', 'course', 'semester'), name='unique-degree-profile'),
),
]
25 changes: 25 additions & 0 deletions backend/degree/migrations/0010_auto_20240324_1732.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Generated by Django 3.2.24 on 2024-03-24 21:32

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('degree', '0009_auto_20240324_1730'),
]

operations = [
migrations.RemoveConstraint(
model_name='coursetaken',
name='unique-degree-profile',
),
migrations.AddConstraint(
model_name='coursetaken',
constraint=models.UniqueConstraint(fields=('degree_profile', 'course', 'semester'), name='unique-course-taken'),
),
migrations.AddConstraint(
model_name='degreeprofile',
constraint=models.UniqueConstraint(fields=('user_profile',), name='unique-degree-profile'),
),
]
20 changes: 20 additions & 0 deletions backend/degree/migrations/0011_alter_coursetaken_course.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Generated by Django 3.2.24 on 2024-03-24 23:06

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('courses', '0066_course_credits'),
('degree', '0010_auto_20240324_1732'),
]

operations = [
migrations.AlterField(
model_name='coursetaken',
name='course',
field=models.ForeignKey(help_text='\nThe course code (e.g. CIS-1210) of the course taken\n', on_delete=django.db.models.deletion.CASCADE, to='courses.course'),
),
]
20 changes: 20 additions & 0 deletions backend/degree/migrations/0012_alter_coursetaken_course.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Generated by Django 3.2.24 on 2024-03-28 05:54

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('courses', '0066_course_credits'),
('degree', '0011_alter_coursetaken_course'),
]

operations = [
migrations.AlterField(
model_name='coursetaken',
name='course',
field=models.ForeignKey(help_text='\nThe full-code (e.g. CIS-1210) of the course taken\n', on_delete=django.db.models.deletion.CASCADE, to='courses.course'),
),
]
20 changes: 20 additions & 0 deletions backend/degree/migrations/0013_alter_coursetaken_course.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Generated by Django 3.2.24 on 2024-03-28 06:33

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('courses', '0066_course_credits'),
('degree', '0012_alter_coursetaken_course'),
]

operations = [
migrations.AlterField(
model_name='coursetaken',
name='course',
field=models.ForeignKey(help_text='\nThe course ID of the course taken\n', on_delete=django.db.models.deletion.CASCADE, to='courses.course'),
),
]
Loading
Loading