diff options
Diffstat (limited to 'archaeological_finds/migrations/0050_auto_20181211_1509.py')
-rw-r--r-- | archaeological_finds/migrations/0050_auto_20181211_1509.py | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/archaeological_finds/migrations/0050_auto_20181211_1509.py b/archaeological_finds/migrations/0050_auto_20181211_1509.py new file mode 100644 index 000000000..c9928d617 --- /dev/null +++ b/archaeological_finds/migrations/0050_auto_20181211_1509.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.10 on 2018-12-11 15:09 +from __future__ import unicode_literals + +from django.db import migrations, models + + +def migrate_treatment_states(apps, schema): + TreatmentState = apps.get_model('archaeological_finds', 'TreatmentState') + q = TreatmentState.objects.filter(txt_idx="completed") + if q.count(): + t = q.all()[0] + t.executed = True + t.save() + for t in TreatmentState.objects.all(): + t.txt_idx = t.txt_idx.replace("_", "-") + t.save() + orders = [(10, "planned"), (20, "to-be-confirmed"), (30, "in-progress"), + (40, "completed"), (50, "cancelled"), (60, "unknown"),] + for order, txt_idx in orders: + q = TreatmentState.objects.filter(txt_idx=txt_idx) + if not q.count(): + continue + t = q.all()[0] + t.order = order + t.save() + + +class Migration(migrations.Migration): + + dependencies = [ + ('archaeological_finds', '0049_auto_20181210_1518'), + ] + + operations = [ + migrations.AlterModelOptions( + name='treatmentstate', + options={'ordering': ('order', 'label'), 'verbose_name': "Type d'\xe9tat de traitement", 'verbose_name_plural': "Types d'\xe9tat de traitement"}, + ), + migrations.AddField( + model_name='treatmentstate', + name='executed', + field=models.BooleanField(default=False, verbose_name='Treatment is executed'), + ), + migrations.AddField( + model_name='treatmentstate', + name='order', + field=models.IntegerField(default=10, verbose_name='Ordre'), + ), + migrations.RunPython(migrate_treatment_states) + ] |