From 6168045c3aaed467d5135fa158ca4e1f311e7049 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Mon, 9 Apr 2018 22:43:25 +0200 Subject: [PATCH] bda: swap double/autoquit descriptions --- bda/migrations/0012_swap_double_choice.py | 53 +++++++++++++++++++++++ bda/models.py | 4 +- 2 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 bda/migrations/0012_swap_double_choice.py diff --git a/bda/migrations/0012_swap_double_choice.py b/bda/migrations/0012_swap_double_choice.py new file mode 100644 index 00000000..56f3e739 --- /dev/null +++ b/bda/migrations/0012_swap_double_choice.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +def swap_double_choice(apps, schema_editor): + choices = apps.get_model("bda", "ChoixSpectacle").objects + + choices.filter(double_choice="double").update(double_choice="tmp") + choices.filter(double_choice="autoquit").update(double_choice="double") + choices.filter(double_choice="tmp").update(double_choice="autoquit") + + +class Migration(migrations.Migration): + + dependencies = [ + ('bda', '0011_tirage_appear_catalogue'), + ] + + operations = [ + # Temporarily allow an extra "tmp" value for the `double_choice` field + migrations.AlterField( + model_name='choixspectacle', + name='double_choice', + field=models.CharField( + verbose_name='Nombre de places', + max_length=10, + default='1', + choices=[ + ('tmp', 'tmp'), + ('1', '1 place'), + ('double', '2 places si possible, 1 sinon'), + ('autoquit', '2 places sinon rien') + ] + ), + ), + migrations.RunPython(swap_double_choice, migrations.RunPython.noop), + migrations.AlterField( + model_name='choixspectacle', + name='double_choice', + field=models.CharField( + verbose_name='Nombre de places', + max_length=10, + default='1', + choices=[ + ('1', '1 place'), + ('double', '2 places si possible, 1 sinon'), + ('autoquit', '2 places sinon rien') + ] + ), + ), + ] diff --git a/bda/models.py b/bda/models.py index 41462d70..63e08221 100644 --- a/bda/models.py +++ b/bda/models.py @@ -170,8 +170,8 @@ class Participant(models.Model): DOUBLE_CHOICES = ( ("1", "1 place"), - ("autoquit", "2 places si possible, 1 sinon"), - ("double", "2 places sinon rien"), + ("double", "2 places si possible, 1 sinon"), + ("autoquit", "2 places sinon rien"), )