From 53e5b5271125894b368ee4a45dc56f95fa8cd6b5 Mon Sep 17 00:00:00 2001 From: Jean-Marie Favreau Date: Sun, 10 Nov 2024 22:28:56 +0100 Subject: [PATCH] On s'assure que les noms des alias sont courts --- .../migrations/0107_strip_aliases.py | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/agenda_culturel/migrations/0107_strip_aliases.py diff --git a/src/agenda_culturel/migrations/0107_strip_aliases.py b/src/agenda_culturel/migrations/0107_strip_aliases.py new file mode 100644 index 0000000..8724346 --- /dev/null +++ b/src/agenda_culturel/migrations/0107_strip_aliases.py @@ -0,0 +1,30 @@ +# Generated by Django 4.2.9 on 2024-11-10 21:25 + +from django.db import migrations + + +def strip_place_aliases(apps, schema_editor): + Place = apps.get_model("agenda_culturel", "Place") + + places = Place.objects.all() + + for p in places: + if not p.aliases is None: + p.aliases = [a.strip() for a in p.aliases] + + Place.objects.bulk_update(places, fields=["aliases"]) + + + +def do_nothing(apps, schema_editor): + pass + +class Migration(migrations.Migration): + + dependencies = [ + ('agenda_culturel', '0106_alter_event_other_versions'), + ] + + operations = [ + migrations.RunPython(strip_place_aliases, reverse_code=do_nothing) + ]