From a82d785c35c698cf4063de8fe144f20e41213ff6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Valentin=20Grou=C3=A8s?= <valentin.groues@uni.lu>
Date: Tue, 25 Apr 2017 11:03:39 +0200
Subject: [PATCH] change some appointment types descriptions - fixes #98

---
 ..._appointment_types_descriptions_changes.py | 43 +++++++++++++++++++
 1 file changed, 43 insertions(+)
 create mode 100644 smash/web/migrations/0037_appointment_types_descriptions_changes.py

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 00000000..a17f554c
--- /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),
+
+    ]
-- 
GitLab