# Generated by Django 3.1 on 2020-08-10 19:22

import django.contrib.auth.models
from django.db import migrations, models
import django.db.models.deletion


def load_defaults_for_order_status(apps, schema_editor):
    OrderStatus = apps.get_model('website', 'OrderStatus')

    status_created = OrderStatus(id=0, label="ORDER_CREATED")
    status_created.save()

    status_paid = OrderStatus(id=1, label="ORDER_PAID")
    status_paid.save()

    status_waiting_for_delivery = OrderStatus(id=2, label="ORDER_WAITING_FOR_DELIVERY")
    status_waiting_for_delivery.save()

    status_delivered = OrderStatus(id=3, label="ORDER_DELIVERED")
    status_delivered.save()

    status_completed = OrderStatus(id=4, label="ORDER_COMPLETED")
    status_completed.save()


def load_defaults_for_advert_status(apps, schema_editor):
    AdvertStatus = apps.get_model('website', 'AdvertStatus')

    status_created = AdvertStatus(id=0, label="ADVERT_DRAFT")
    status_created.save()

    status_created = AdvertStatus(id=1, label="ADVERT_WAITING_FOR_REVIEW")
    status_created.save()

    status_created = AdvertStatus(id=2, label="ADVERT_ACTIVE")
    status_created.save()

    status_created = AdvertStatus(id=3, label="ADVERT_RESERVED")
    status_created.save()

    status_created = AdvertStatus(id=4, label="ADVERT_INACTIVE")
    status_created.save()

    status_created = AdvertStatus(id=5, label="ADVERT_COMPLETED")
    status_created.save()


def load_root_category(apps, schema_editor):
    Category = apps.get_model('website', 'Category')

    status_created = Category(id=0, name="Все", url='root')
    status_created.save()

class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('website', '0001_initial'),
    ]

    operations = [
        migrations.RunPython(load_defaults_for_advert_status),
        migrations.RunPython(load_defaults_for_order_status),
        migrations.RunPython(load_root_category),
    ]
