# Generated by Django 2.2 on 2019-12-02 11:29
import uuid

from django.db import migrations
from django.utils.text import slugify


def generate_slug(apps, schema_editor):
    one_c = apps.get_model('production', 'OneC')
    online_cashbox = apps.get_model('production', 'OnlineCashbox')

    for item in one_c.objects.all():
        item.slug = slugify(item.title) + str(uuid.uuid4())
        item.save()

    for item in online_cashbox.objects.all():
        item.slug = slugify(item.title) + str(uuid.uuid4())
        item.save()


class Migration(migrations.Migration):
    dependencies = [
        ('production', '0020_auto_20191202_1127'),
    ]

    operations = [
        migrations.RunPython(generate_slug, reverse_code=migrations.RunPython.noop)
    ]
