# Generated by Django 3.1.7 on 2021-04-03 14:12

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
import store.models
import store.utils


class Migration(migrations.Migration):

    initial = True

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

    operations = [
        migrations.CreateModel(
            name='Article',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('title', models.CharField(max_length=255, verbose_name='Заголовок')),
                ('name', models.CharField(blank=True, max_length=50, verbose_name='Пункт меню')),
                ('slug', models.SlugField(unique=True)),
                ('content', models.TextField(null=True, verbose_name='Текст страницы')),
            ],
            options={
                'verbose_name': 'Страница',
                'verbose_name_plural': 'Страницы',
                'ordering': ('id',),
            },
        ),
        migrations.CreateModel(
            name='Category',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=255, verbose_name='Имя категории')),
                ('slug', models.SlugField(unique=True)),
            ],
            options={
                'verbose_name': 'Группа',
                'verbose_name_plural': 'Группы',
                'ordering': ('id',),
            },
        ),
        migrations.CreateModel(
            name='Customer',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('session', models.CharField(blank=True, max_length=200, null=True, verbose_name='Сессия клиента')),
                ('created', models.DateTimeField(auto_now=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')),
                ('total_products', models.PositiveIntegerField(default=0, verbose_name='Товары')),
                ('total_price_net', models.DecimalField(decimal_places=2, default=0, max_digits=9, verbose_name='Сумма товаров')),
                ('total_price_gross', models.DecimalField(decimal_places=2, default=0, max_digits=9, verbose_name='Общая сумма')),
                ('status', models.CharField(choices=[('cart', 'Корзина'), ('new', 'Оформлен'), ('in_progress', 'В обработке'), ('is_ready', 'Готов'), ('shipped', 'Отправлен'), ('delivered', 'Доставлен в место выдачи'), ('received', 'Получен'), ('return', 'Возврат'), ('canceled', 'Отменен')], default='cart', max_length=100, verbose_name='Статус заказа')),
                ('delivery_type', models.CharField(choices=[('self', 'Самовывоз из мастерской (бесплатно)'), ('delivery_cdekspb', 'Доставка до пункта выдачи СДЭК по СПб'), ('delivery_spb', 'Курьерская доставка по СПб'), ('delivery_ru', 'Почтовая отправка по России'), ('delivery_world', 'Почтовая отправка за рубеж')], default=None, max_length=100, null=True, verbose_name='Тип заказа')),
                ('delivery_cost', models.DecimalField(decimal_places=2, default=0, max_digits=9, verbose_name='Стоимость доставки')),
                ('payment_type', models.CharField(choices=[('cash_card', 'Наличные или банковская карта в мастерской'), ('bankcard', 'Банковская карта онлайн'), ('wallet', 'Kiwi кошелёк / Paypal')], default=None, max_length=100, null=True, verbose_name='Способ оплаты')),
                ('comment', models.TextField(blank=True, null=True, verbose_name='Комментарий к заказу')),
                ('remark', models.CharField(blank=True, help_text='Служебные примечания, клиенту недоступны', max_length=255, null=True, verbose_name='Примечания от магазина')),
                ('created_at', models.DateTimeField(default=django.utils.timezone.now, verbose_name='Дата заказа')),
                ('is_paid', models.BooleanField(default=False, verbose_name='Оплачен')),
                ('shipped_date', models.DateTimeField(blank=True, null=True)),
                ('tracking', models.CharField(blank=True, max_length=50, null=True, verbose_name='Трекинг номер')),
                ('first_name', models.CharField(blank=True, max_length=50, verbose_name='Имя')),
                ('last_name', models.CharField(blank=True, max_length=50, verbose_name='Фамилия')),
                ('patronymic', models.CharField(blank=True, max_length=50, verbose_name='Отчество')),
                ('phone', models.CharField(blank=True, max_length=20, verbose_name='Телефон')),
                ('settlement', models.CharField(blank=True, max_length=100, verbose_name='Населенный пункт')),
                ('address', models.CharField(blank=True, max_length=1024, verbose_name='Адрес')),
                ('postal_code', models.CharField(blank=True, max_length=30, verbose_name='Индекс')),
            ],
            options={
                'verbose_name': 'Заказ',
                'verbose_name_plural': '1. Заказы',
            },
        ),
        migrations.CreateModel(
            name='Parameter',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=255, verbose_name='Имя')),
                ('value', models.IntegerField(verbose_name='Значение')),
                ('meaning', models.TextField(blank=True, null=True, verbose_name='Описание')),
            ],
            options={
                'verbose_name': 'Параметр',
                'verbose_name_plural': 'Параметры',
                'ordering': ('name',),
            },
        ),
        migrations.CreateModel(
            name='Product',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('title', models.CharField(max_length=255, verbose_name='Наименование')),
                ('slug', models.SlugField(unique=True)),
                ('image', models.ImageField(upload_to=store.utils.path_and_rename, verbose_name='Изображение')),
                ('description', models.TextField(null=True, verbose_name='Описание')),
                ('care', models.TextField(blank=True, null=True, verbose_name='Инструкция по уходу')),
                ('price', models.DecimalField(decimal_places=2, max_digits=9, verbose_name='Цена')),
                ('price_discount', models.DecimalField(blank=True, decimal_places=2, max_digits=9, null=True, verbose_name='Цена со скидкой')),
                ('length', models.IntegerField(blank=True, null=True, verbose_name='Длина, см')),
                ('width', models.IntegerField(blank=True, null=True, verbose_name='Ширина, см')),
                ('height', models.IntegerField(blank=True, null=True, verbose_name='Высота, см')),
                ('weight', models.IntegerField(blank=True, null=True, verbose_name='Вес, гр')),
                ('material', models.CharField(blank=True, max_length=20, null=True, verbose_name='Материал')),
                ('color', models.CharField(blank=True, max_length=20, null=True, verbose_name='Цвет')),
                ('bestseller', models.BooleanField(default=False, verbose_name='Хит')),
                ('new', models.BooleanField(default=False, verbose_name='Новинка')),
                ('gift', models.BooleanField(default=False, verbose_name='Подарок')),
                ('gender', models.CharField(choices=[('G', 'Для всех'), ('M', 'Для мужчин'), ('F', 'Для женщин')], default='G', max_length=1, verbose_name='Пол')),
                ('quantity', models.PositiveIntegerField(default=0, verbose_name='Наличие')),
                ('display', models.BooleanField(default=True, verbose_name='Выставлять')),
                ('limited', models.BooleanField(default=False, verbose_name='Лимитированный выпуск')),
                ('date_added', models.DateTimeField(auto_now_add=True, verbose_name='Добавлен')),
                ('visits', models.IntegerField(default=0, help_text='Количество просмотров', verbose_name='👁')),
                ('last_visit', models.DateTimeField(blank=True, null=True, verbose_name='Просмотрен')),
                ('category', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='store.category', verbose_name='Категория')),
            ],
            options={
                'verbose_name': 'Товар',
                'verbose_name_plural': '2. Товары',
                'ordering': ('subcategory', 'title'),
            },
        ),
        migrations.CreateModel(
            name='SubCategory',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=255, verbose_name='Подгруппа')),
                ('slug', models.SlugField(unique=True)),
                ('category', models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, to='store.category', verbose_name='Группа')),
            ],
            options={
                'verbose_name': 'Подгруппа',
                'verbose_name_plural': 'Подгруппы',
                'ordering': ('category', 'name'),
            },
        ),
        migrations.CreateModel(
            name='ProductImage',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('image', models.ImageField(upload_to='')),
                ('product', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='store.product')),
            ],
            options={
                'verbose_name': 'Изображение товара',
                'verbose_name_plural': 'Изображения товара',
            },
        ),
        migrations.AddField(
            model_name='product',
            name='subcategory',
            field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, to='store.subcategory', verbose_name='Подгруппа'),
        ),
        migrations.CreateModel(
            name='OrderProduct',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('qty', models.PositiveIntegerField(default=1, verbose_name='шт')),
                ('final_price', models.DecimalField(decimal_places=2, max_digits=9, verbose_name='Общая цена')),
                ('order', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='related_products', to='store.order', verbose_name='Корзина')),
                ('product', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='store.product', verbose_name='Товар')),
            ],
            options={
                'verbose_name': 'Товар заказа',
                'verbose_name_plural': 'Товары заказа',
            },
        ),
        migrations.AddField(
            model_name='order',
            name='gift',
            field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.DO_NOTHING, to='store.product', verbose_name='Подарок'),
        ),
        migrations.AddField(
            model_name='order',
            name='owner',
            field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='store.customer', verbose_name='Покупатель'),
        ),
        migrations.AddField(
            model_name='order',
            name='products',
            field=models.ManyToManyField(blank=True, related_name='related_cart', to='store.OrderProduct'),
        ),
        migrations.AddField(
            model_name='customer',
            name='orders',
            field=models.ManyToManyField(related_name='related_order', to='store.Order', verbose_name='Заказы клиента'),
        ),
        migrations.AddField(
            model_name='customer',
            name='user',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL),
        ),
    ]
