summaryrefslogtreecommitdiff
path: root/ishtar_common/migrations/0238_biographicalnote_slug.py
blob: faa25d699750209643775c7ee049cdd1eddee88c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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'),
        ),
    ]