On s'assure que les noms des alias sont courts
This commit is contained in:
parent
b1dcd55ebc
commit
53e5b52711
30
src/agenda_culturel/migrations/0107_strip_aliases.py
Normal file
30
src/agenda_culturel/migrations/0107_strip_aliases.py
Normal file
@ -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)
|
||||||
|
]
|
Loading…
Reference in New Issue
Block a user