# Generated by Django 2.1.3 on 2018-11-08 09:36

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import mptt.fields


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='Category',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=80, verbose_name='name')),
                ('slug', models.SlugField(unique=True, verbose_name='slug')),
                ('short_description', models.TextField(blank=True, verbose_name='краткое описание')),
                ('description', models.TextField(blank=True, verbose_name='описание')),
                ('is_active', models.BooleanField(default=True, verbose_name='активен')),
                ('sort', models.PositiveSmallIntegerField(default=1, verbose_name='сортировка')),
                ('lft', models.PositiveIntegerField(db_index=True, editable=False)),
                ('rght', models.PositiveIntegerField(db_index=True, editable=False)),
                ('tree_id', models.PositiveIntegerField(db_index=True, editable=False)),
                ('level', models.PositiveIntegerField(db_index=True, editable=False)),
                ('parent', mptt.fields.TreeForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='shop.Category', verbose_name='parent node')),
            ],
            options={
                'verbose_name': 'категория',
                'verbose_name_plural': 'категории',
                'ordering': ['sort'],
            },
        ),
        migrations.CreateModel(
            name='Option',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=200, unique=True, verbose_name='Наименование')),
            ],
            options={
                'verbose_name': 'опция',
                'verbose_name_plural': 'опции для товара',
            },
        ),
        migrations.CreateModel(
            name='Order',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('number', models.CharField(editable=False, max_length=10, unique=True, verbose_name='order number')),
                ('status', models.IntegerField(choices=[(1, 'Created'), (2, 'Confirmed'), (3, 'Denied'), (4, 'Shipped'), (5, 'Completed')], default=1, verbose_name='order status')),
                ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='creation date')),
                ('updated_at', models.DateTimeField(auto_now=True, verbose_name='updated at')),
                ('delivered_at', models.DateTimeField(blank=True, editable=False, null=True, verbose_name='delivery date')),
                ('city', models.CharField(blank=True, max_length=80, null=True, verbose_name='город')),
                ('address', models.TextField(blank=True, null=True, verbose_name='адрес доставки')),
                ('zip_code', models.CharField(blank=True, max_length=24, null=True, verbose_name='индекс')),
                ('phone', models.CharField(max_length=80, verbose_name='телефон')),
                ('ip_address', models.CharField(blank=True, max_length=80, null=True, verbose_name='IP')),
                ('comment', models.TextField(blank=True, verbose_name='комментарий')),
            ],
            options={
                'verbose_name': 'заказ',
                'verbose_name_plural': 'заказы',
                'ordering': ['-created_at'],
            },
        ),
        migrations.CreateModel(
            name='OrderProducts',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('quantity', models.PositiveIntegerField(default=1, verbose_name='quantity')),
                ('order', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='ordered_items', to='shop.Order', verbose_name='order')),
            ],
            options={
                'verbose_name': 'order product',
                'verbose_name_plural': 'order product',
            },
        ),
        migrations.CreateModel(
            name='Product',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('meta_title', models.CharField(blank=True, max_length=200, verbose_name='Заголовок')),
                ('meta_keywords', models.CharField(blank=True, max_length=300, verbose_name='Ключевые слова')),
                ('meta_description', models.TextField(blank=True, verbose_name='Описание')),
                ('name', models.CharField(max_length=200, verbose_name='name')),
                ('slug', models.SlugField(unique=True, verbose_name='slug')),
                ('price', models.PositiveIntegerField(verbose_name='price')),
                ('is_active', models.BooleanField(default=True, verbose_name='активен')),
                ('short_description', models.TextField(blank=True, verbose_name='краткое описание')),
                ('description', models.TextField(blank=True, verbose_name='описание')),
                ('sort', models.PositiveSmallIntegerField(default=1, verbose_name='сортировка')),
                ('category', mptt.fields.TreeForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='products', to='shop.Category', verbose_name='category')),
            ],
            options={
                'verbose_name': 'товар',
                'verbose_name_plural': 'товары',
                'ordering': ('sort',),
            },
        ),
        migrations.CreateModel(
            name='ProductImage',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('sort', models.PositiveSmallIntegerField(default=1, verbose_name='сортировка')),
                ('image', models.ImageField(upload_to='uploads/products/', verbose_name='изображение')),
                ('product', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='images', to='shop.Product', verbose_name='товар')),
            ],
            options={
                'verbose_name': 'изображение товара',
                'verbose_name_plural': 'изображения товара',
                'ordering': ('sort',),
            },
        ),
        migrations.CreateModel(
            name='ProductOption',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('value', models.CharField(default='', max_length=200, verbose_name='значение')),
                ('sort', models.PositiveSmallIntegerField(default=1, verbose_name='сортировка')),
                ('option', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='shop.Option', verbose_name='опция')),
                ('product', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='options', to='shop.Product', verbose_name='товар')),
            ],
            options={
                'verbose_name': 'характеристика товара',
                'verbose_name_plural': 'характеристики товара',
                'ordering': ('sort',),
            },
        ),
        migrations.CreateModel(
            name='ProductVideo',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('embeded', models.TextField(verbose_name='Код для видео')),
                ('sort', models.PositiveSmallIntegerField(default=1, verbose_name='сортировка')),
                ('product', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='videos', to='shop.Product', verbose_name='товар')),
            ],
            options={
                'verbose_name': 'видео для товара',
                'verbose_name_plural': 'видео для товара',
                'ordering': ('sort',),
            },
        ),
        migrations.CreateModel(
            name='ShippingType',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=100, verbose_name='способ доставки')),
                ('price', models.PositiveIntegerField(default=0, verbose_name='цена')),
                ('require_address', models.BooleanField(default=False, verbose_name='необходимо указать адрес')),
                ('require_zip_code', models.BooleanField(default=False, verbose_name='необходимо указать индекс')),
                ('help', models.TextField(blank=True, null=True, verbose_name='подсказка')),
                ('sort', models.PositiveSmallIntegerField(default=1, verbose_name='сортировка')),
                ('is_active', models.BooleanField(default=True, verbose_name='активен')),
            ],
            options={
                'verbose_name': 'способ доставки',
                'verbose_name_plural': 'способы доставки',
                'ordering': ('sort',),
            },
        ),
        migrations.AddField(
            model_name='orderproducts',
            name='product',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='shop.Product', verbose_name='product'),
        ),
        migrations.AddField(
            model_name='order',
            name='products',
            field=models.ManyToManyField(related_name='products', through='shop.OrderProducts', to='shop.Product', verbose_name='products'),
        ),
        migrations.AddField(
            model_name='order',
            name='shipping_type',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='orders', to='shop.ShippingType', verbose_name='способ доставки'),
        ),
        migrations.AddField(
            model_name='order',
            name='user',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='orders', to=settings.AUTH_USER_MODEL, verbose_name='user'),
        ),
    ]
