# Generated by Django 2.2.4 on 2019-08-31 14:09
from django.db import migrations, models
from django.utils.text import slugify


def set_import_id(apps, schema_editor):
    DocumentTemplate = apps.get_model('document', 'DocumentTemplate')
    for dt in DocumentTemplate.objects.all():
        title = dt.title
        if len(title) == 0:
            title = 'default'
        dt.import_id = slugify(title, allow_unicode=False)
        dt.save()


class Migration(migrations.Migration):

    dependencies = [
        ('document', '0017_remove_documenttemplate_citation_styles'),
    ]

    operations = [
        migrations.AddField(
            model_name='documenttemplate',
            name='import_id',
            field=models.CharField(blank=True, default='', max_length=255),
        ),
        migrations.RunPython(set_import_id),
    ]
