-
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
- Loading branch information
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
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,31 @@ | ||
# 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), | ||
] |