|
| 1 | +from django.db import migrations |
| 2 | + |
| 3 | + |
| 4 | +def create_radiation_protection_certification(apps, schema_editor): |
| 5 | + """Create the radiation protection certification.""" |
| 6 | + from ..constants import RADIATION_PROTECTION_CERTIFICATION_NAME |
| 7 | + from certification.certifications.models import CertificationType |
| 8 | + |
| 9 | + Certification = apps.get_model("certification", "Certification") |
| 10 | + |
| 11 | + Certification.objects.get_or_create( |
| 12 | + name=RADIATION_PROTECTION_CERTIFICATION_NAME, |
| 13 | + defaults={ |
| 14 | + "type_of": CertificationType.QUIZ, |
| 15 | + "description": "Radiation protection certification for AGLAE beamline users", |
| 16 | + "num_days_valid": 365, |
| 17 | + "invitation_to_complete_email_template_path": "radiation_protection/email/radioprotection_invitation.html", |
| 18 | + "success_email_template_path": "radiation_protection/email/radioprotection_success.html", |
| 19 | + }, |
| 20 | + ) |
| 21 | + |
| 22 | + |
| 23 | +def remove_radiation_protection_certification(apps, schema_editor): |
| 24 | + """Remove the radiation protection certification.""" |
| 25 | + from ..constants import RADIATION_PROTECTION_CERTIFICATION_NAME |
| 26 | + |
| 27 | + Certification = apps.get_model("certification", "Certification") |
| 28 | + Certification.objects.filter(name=RADIATION_PROTECTION_CERTIFICATION_NAME).delete() |
| 29 | + |
| 30 | + |
| 31 | +class Migration(migrations.Migration): |
| 32 | + dependencies = [ |
| 33 | + ("certification", "0002_alter_certificationnotification_type_of"), |
| 34 | + ] |
| 35 | + |
| 36 | + operations = [ |
| 37 | + migrations.RunPython( |
| 38 | + create_radiation_protection_certification, |
| 39 | + remove_radiation_protection_certification, |
| 40 | + ), |
| 41 | + ] |
0 commit comments