From d1890dc252f7f75c8b7dd5166e7fd145f7db5379 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Mon, 26 Feb 2024 11:41:41 +0100 Subject: 🗃️ add slug to biographical notes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../migrations/0238_biographicalnote_slug.py | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 ishtar_common/migrations/0238_biographicalnote_slug.py (limited to 'ishtar_common/migrations') diff --git a/ishtar_common/migrations/0238_biographicalnote_slug.py b/ishtar_common/migrations/0238_biographicalnote_slug.py new file mode 100644 index 000000000..faa25d699 --- /dev/null +++ b/ishtar_common/migrations/0238_biographicalnote_slug.py @@ -0,0 +1,35 @@ +# Generated by Django 2.2.24 on 2024-02-26 11:40 + +from django.db import migrations, models +from ishtar_common.utils import create_slug + + +def set_slug(apps, __): + BiographicalNote = apps.get_model('ishtar_common', 'BiographicalNote') + for bn in BiographicalNote.objects.all(): + bn.slug = create_slug(BiographicalNote, bn.denomination, max_length=250, pk=bn.pk) + bn.skip_history_when_saving = True + bn.save() + + +class Migration(migrations.Migration): + + dependencies = [ + ('ishtar_common', '0237_data_migration_licenses_shootingangle'), + ] + + operations = [ + migrations.AddField( + model_name='biographicalnote', + name='slug', + field=models.SlugField(blank=True, help_text='The slug is the standardized version of the name. It contains only lowercase letters, numbers and hyphens. Each slug must be unique.', max_length=300, null=True, verbose_name='Textual ID'), + ), + migrations.RunPython(set_slug), + migrations.AlterField( + model_name='biographicalnote', + name='slug', + field=models.SlugField(blank=True, + help_text='The slug is the standardized version of the name. It contains only lowercase letters, numbers and hyphens. Each slug must be unique.', + max_length=300, verbose_name='Textual ID'), + ), + ] -- cgit v1.2.3