forked from openedx/edx-platform
-
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.
Merge pull request openedx#34118 from openedx/dkaplan1/APER-1322_cert…
…s-with-invalidation-records-arent-in-the-unavailable-status feat: data migration for some ancient legacy problems
- Loading branch information
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
lms/djangoapps/certificates/migrations/0037_fix_legacy_broken_invalid_certs.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,32 @@ | ||
# Generated by Django 3.2.23 on 2024-01-25 21:56 | ||
|
||
from django.db import migrations | ||
|
||
from lms.djangoapps.certificates.data import CertificateStatuses | ||
|
||
|
||
class Migration(migrations.Migration): | ||
""" | ||
If any certificates exist with an invalidation record that are not marked as unavailable, | ||
change their status. Irreversible. | ||
""" | ||
|
||
dependencies = [ | ||
("certificates", "0036_modifiedcertificatetemplatecommandconfiguration"), | ||
] | ||
|
||
def make_invalid_certificates_unavailable(apps, schema_editor): | ||
GeneratedCertificate = apps.get_model("certificates", "GeneratedCertificate") | ||
|
||
GeneratedCertificate.objects.filter( | ||
certificateinvalidation__active=True | ||
).exclude(status=CertificateStatuses.unavailable).update( | ||
status=CertificateStatuses.unavailable | ||
) | ||
|
||
operations = [ | ||
migrations.RunPython( | ||
make_invalid_certificates_unavailable, | ||
reverse_code=migrations.RunPython.noop, | ||
) | ||
] |