diff --git a/smash/web/migrations/0037_appointment_types_descriptions_changes.py b/smash/web/migrations/0037_appointment_types_descriptions_changes.py new file mode 100644 index 0000000000000000000000000000000000000000..a17f554c73ed4bc9f4854a8e509f4a94a4aefc2b --- /dev/null +++ b/smash/web/migrations/0037_appointment_types_descriptions_changes.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.3 on 2017-04-20 14:35 +from __future__ import unicode_literals + +from django.db import migrations + +updates_to_perform = [ + ("SB", "Skin Biopsy", "Level B Skin Biopsy"), + ("B", "Level B NP", "Level B"), + ("PSP", "Level B PSP", "PSP"), +] + + +def add_prefixes(apps, schema_editor): + AppointmentType = apps.get_model("web", "AppointmentType") + for update_to_perform in updates_to_perform: + code, description, _ = update_to_perform + appointment_type = AppointmentType.objects.filter(code=code).first() + if appointment_type is not None: + appointment_type.description = description + appointment_type.save() + + +def revert_prefixes(apps, schema_editor): + AppointmentType = apps.get_model("web", "AppointmentType") + for update_to_perform in updates_to_perform: + code, _, previous_description = update_to_perform + appointment_type = AppointmentType.objects.filter(code=code).first() + if appointment_type is not None: + appointment_type.description = previous_description + appointment_type.save() + + +class Migration(migrations.Migration): + dependencies = [ + ('web', '0036_year_of_diagnosis_default'), + ] + + operations = [ + + migrations.RunPython(add_prefixes, reverse_code=revert_prefixes), + + ]