diff --git a/smash/web/migrations/0025_configurationitem_calendar_items.py b/smash/web/migrations/0025_configurationitem_calendar_items.py new file mode 100644 index 0000000000000000000000000000000000000000..a5c6a47127bfd6bb95daf65b8e5fb3cd07e92db5 --- /dev/null +++ b/smash/web/migrations/0025_configurationitem_calendar_items.py @@ -0,0 +1,35 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.3 on 2017-04-04 09:43 +from __future__ import unicode_literals + +from django.db import migrations + +from web.models.constants import CANCELLED_APPOINTMENT_COLOR_CONFIGURATION_TYPE, \ + NO_SHOW_APPOINTMENT_COLOR_CONFIGURATION_TYPE + + +def configuration_item_color_fields(apps, schema_editor): + # We can't import the ConfigurationItem model directly as it may be a newer + # version than this migration expects. We use the historical version. + ConfigurationItem = apps.get_model("web", "ConfigurationItem") + cancelled_appointment_color = ConfigurationItem.objects.create() + cancelled_appointment_color.type = CANCELLED_APPOINTMENT_COLOR_CONFIGURATION_TYPE + cancelled_appointment_color.value = "#b7babf" + cancelled_appointment_color.name = "Color for cancelled appointments" + cancelled_appointment_color.save() + + cancelled_appointment_color = ConfigurationItem.objects.create() + cancelled_appointment_color.type = NO_SHOW_APPOINTMENT_COLOR_CONFIGURATION_TYPE + cancelled_appointment_color.value = "#ff0000" + cancelled_appointment_color.name = "Color for NO SHOW appointments" + cancelled_appointment_color.save() + + +class Migration(migrations.Migration): + dependencies = [ + ('web', '0024_configurationitem'), + ] + + operations = [ + migrations.RunPython(configuration_item_color_fields), + ] diff --git a/smash/web/models/constants.py b/smash/web/models/constants.py index 333f0baa2a66ea3c4e2e7c1b0437e5ac3f566200..cb52bd3aba0b11d401ed4b118ad0c36db26338fb 100644 --- a/smash/web/models/constants.py +++ b/smash/web/models/constants.py @@ -27,3 +27,6 @@ CONTACT_TYPES_CHOICES = ( (CONTACT_TYPES_PHONE, 'Phone'), (CONTACT_TYPES_SMS, 'SMS'), ) + +CANCELLED_APPOINTMENT_COLOR_CONFIGURATION_TYPE = "CANCELLED_APPOINTMENT_COLOR" +NO_SHOW_APPOINTMENT_COLOR_CONFIGURATION_TYPE = "NO_SHOW_APPOINTMENT_COLOR" diff --git a/smash/web/tests/test_model_configuration_item.py b/smash/web/tests/test_model_configuration_item.py new file mode 100644 index 0000000000000000000000000000000000000000..be211a79adbe5b8312395ecb952458904d325d64 --- /dev/null +++ b/smash/web/tests/test_model_configuration_item.py @@ -0,0 +1,14 @@ +from django.test import TestCase + +from web.models import ConfigurationItem +from web.models.constants import CANCELLED_APPOINTMENT_COLOR_CONFIGURATION_TYPE, \ + NO_SHOW_APPOINTMENT_COLOR_CONFIGURATION_TYPE + + +class ConfigurationItemModelTests(TestCase): + def test_init_data(self): + items = ConfigurationItem.objects.filter(type=CANCELLED_APPOINTMENT_COLOR_CONFIGURATION_TYPE) + self.assertTrue(len(items) > 0) + + items = ConfigurationItem.objects.filter(type=NO_SHOW_APPOINTMENT_COLOR_CONFIGURATION_TYPE) + self.assertTrue(len(items) > 0)