Skip to content

Commit

Permalink
Merge pull request openedx#34118 from openedx/dkaplan1/APER-1322_cert…
Browse files Browse the repository at this point in the history
…s-with-invalidation-records-arent-in-the-unavailable-status

feat: data migration for some ancient legacy problems
  • Loading branch information
deborahgu authored Jan 29, 2024
2 parents c456781 + 2538531 commit ffd4a54
Showing 1 changed file with 32 additions and 0 deletions.
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,
)
]

0 comments on commit ffd4a54

Please sign in to comment.