-
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.
Rectivate enrollments for Differential Calculus (#2325)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
c181ef8
commit 8cfe212
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
courses/migrations/0053_reactivate_wrong_program_enrollments.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,33 @@ | ||
# Generated by Django 3.2.25 on 2024-08-05 14:45 | ||
|
||
from django.db import migrations | ||
|
||
|
||
def deactivate_program_enrollments(apps, schema_editor): | ||
"""Deactivate all Enrollments for this not yet live program 18.03x Differential Equations | ||
and activate back for Differential Calculus | ||
""" | ||
ProgramEnrollments = apps.get_model("courses", "ProgramEnrollment") | ||
enrollments = ProgramEnrollments.objects.filter( | ||
program__readable_id="program-v1:MITxT+18.01x" | ||
) | ||
for enrollment in enrollments: | ||
enrollment.active = True | ||
enrollment.save() | ||
|
||
enrollments = ProgramEnrollments.objects.filter( | ||
program__readable_id="program-v1:MITxT+18.03x" | ||
) | ||
for enrollment in enrollments: | ||
enrollment.active = False | ||
enrollment.save() | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("courses", "0052_deactivate_enrollments"), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(deactivate_program_enrollments, migrations.RunPython.noop), | ||
] |