<reponame>bzg/acceslibre
# Generated by Django 3.2 on 2021-05-05 15:30

import django.contrib.postgres.fields
from django.db import migrations, models


def migrate_sonnette_to_bouton(apps, schema_editor):
    Accessibilite = apps.get_model("erp", "Accessibilite")
    for a in Accessibilite.objects.all():
        if "sonnette" in a.entree_dispositif_appel_type:
            a.entree_dispositif_appel_type.remove("sonnette")
            if "bouton" not in a.entree_dispositif_appel_type:
                a.entree_dispositif_appel_type.append("bouton")
            a.save()


class Migration(migrations.Migration):
    dependencies = [
        ("erp", "0119_alter_accessibilite_cheminement_ext_pente_longueur"),
    ]

    operations = [
        migrations.RunPython(migrate_sonnette_to_bouton),
        migrations.AlterField(
            model_name="accessibilite",
            name="entree_dispositif_appel_type",
            field=django.contrib.postgres.fields.ArrayField(
                base_field=models.CharField(
                    blank=True,
                    choices=[
                        ("bouton", "Bouton d’appel"),
                        ("interphone", "Interphone"),
                        ("visiophone", "Visiophone"),
                    ],
                    max_length=255,
                ),
                blank=True,
                default=list,
                null=True,
                size=None,
                verbose_name="Dispositifs d'appel disponibles",
            ),
        ),
    ]

# Generated by Django 3.2 on 2021-05-05 15:30

import django.contrib.postgres.fields
from django.db import migrations, models


def migrate_sonnette_to_bouton(apps, schema_editor):
    Accessibilite = apps.get_model("erp", "Accessibilite")
    for a in Accessibilite.objects.all():
        if "sonnette" in a.entree_dispositif_appel_type:
            a.entree_dispositif_appel_type.remove("sonnette")
            if "bouton" not in a.entree_dispositif_appel_type:
                a.entree_dispositif_appel_type.append("bouton")
            a.save()


class Migration(migrations.Migration):
    dependencies = [
        ("erp", "0119_alter_accessibilite_cheminement_ext_pente_longueur"),
    ]

    operations = [
        migrations.RunPython(migrate_sonnette_to_bouton),
        migrations.AlterField(
            model_name="accessibilite",
            name="entree_dispositif_appel_type",
            field=django.contrib.postgres.fields.ArrayField(
                base_field=models.CharField(
                    blank=True,
                    choices=[
                        ("bouton", "Bouton d’appel"),
                        ("interphone", "Interphone"),
                        ("visiophone", "Visiophone"),
                    ],
                    max_length=255,
                ),
                blank=True,
                default=list,
                null=True,
                size=None,
                verbose_name="Dispositifs d'appel disponibles",
            ),
        ),
    ]
# Generated by Django 3.2 on 2021-05-05 15:30