-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactors serializers/views for speed in enrollment APIs, adds flag t…
…o designate requirements as electives or not (#1736) - Adds a flag to the ProgramRequirement model to signify if a node contains electives or not (only valid for depth=2) - Some updates to use said flag rather than rely on the node title - Refactored some computed properties that were using recursion to walk the requirements tree to instead pull flat lists - Refactored the Program.courses computed property to use the new node flag
- Loading branch information
Showing
9 changed files
with
163 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
courses/migrations/0037_update_programrequirements_add_elective_flag.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Generated by Django 3.2.18 on 2023-07-10 15:41 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
def forwards_func(apps, schema_editor): | ||
ProgramRequirement = apps.get_model("courses", "ProgramRequirement") | ||
db_alias = schema_editor.connection.alias | ||
update_reqs = ( | ||
ProgramRequirement.objects.using(db_alias) | ||
.filter(depth=2, title="Elective Courses") | ||
.all() | ||
) | ||
|
||
for requirement in update_reqs: | ||
requirement.elective_flag = True | ||
|
||
ProgramRequirement.objects.using(db_alias).bulk_update( | ||
update_reqs, ["elective_flag"] | ||
) | ||
|
||
|
||
def reverse_func(apps, schema_editor): | ||
# just here to make this reversible - the field goes away on down so nothing to do here | ||
return | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("courses", "0036_update_letter_grades_for_dedp"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="programrequirement", | ||
name="elective_flag", | ||
field=models.BooleanField(blank=True, default=False, null=True), | ||
), | ||
migrations.RunPython( | ||
forwards_func, | ||
reverse_func, | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.