# Generated by Django 2.2.16 on 2022-04-12 13:28

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('sales_backend', '0001_initial'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='Chat',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('type', models.CharField(choices=[('D', 'Dialog'), ('C', 'Chat')], default='D', max_length=1, verbose_name='Тип')),
                ('members', models.ManyToManyField(to=settings.AUTH_USER_MODEL, verbose_name='Участник')),
            ],
        ),
        migrations.CreateModel(
            name='Order',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('address', models.CharField(max_length=250)),
                ('postal_code', models.CharField(max_length=20)),
                ('city', models.CharField(max_length=100)),
                ('created', models.DateTimeField(auto_now_add=True)),
                ('updated', models.DateTimeField(auto_now=True)),
                ('paid', models.BooleanField(default=False)),
                ('status_order', models.CharField(choices=[('В обработке', 'В обработке'), ('Заказ собран', 'Заказ собран'), ('Заказ отправлен', 'Заказ отправлен')], default='В обработке', max_length=20)),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='user', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'verbose_name_plural': 'Заказы',
                'ordering': ('-created',),
            },
        ),
        migrations.CreateModel(
            name='OrderItem',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('price', models.DecimalField(decimal_places=2, max_digits=10)),
                ('quantity', models.PositiveIntegerField(default=1)),
                ('order', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='items', to='orders.Order')),
                ('product', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='order_items', to='sales_backend.Product')),
                ('seller', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='seller', to=settings.AUTH_USER_MODEL)),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='order_users', to=settings.AUTH_USER_MODEL)),
            ],
        ),
        migrations.CreateModel(
            name='Message',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('message', models.TextField(verbose_name='Сообщение')),
                ('pub_date', models.DateTimeField(default=django.utils.timezone.now, verbose_name='Дата сообщения')),
                ('is_readed', models.BooleanField(default=False, verbose_name='Прочитано')),
                ('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='Пользователь')),
                ('chat', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='orders.Chat', verbose_name='Чат')),
            ],
            options={
                'ordering': ['pub_date'],
            },
        ),
        migrations.AddConstraint(
            model_name='orderitem',
            constraint=models.CheckConstraint(check=models.Q(_negated=True, user=django.db.models.expressions.F('seller')), name='dont_buy_yourself'),
        ),
    ]

[(16, 'django.db.migrations.swappable_dependency', 'migrations.swappable_dependency', (['settings.AUTH_USER_MODEL'], {}), False, 'from django.db import migrations, models\n'), (23, 'django.db.models.AutoField', 'models.AutoField', ([], {'auto_created': '(True)', 'primary_key': '(True)', 'serialize': '(False)', 'verbose_name': '"""ID"""'}), False, 'from django.db import migrations, models\n'), (24, 'django.db.models.CharField', 'models.CharField', ([], {'choices': "[('D', 'Dialog'), ('C', 'Chat')]", 'default': '"""D"""', 'max_length': '(1)', 'verbose_name': '"""Тип"""'}), False, 'from django.db import migrations, models\n'), (25, 'django.db.models.ManyToManyField', 'models.ManyToManyField', ([], {'to': 'settings.AUTH_USER_MODEL', 'verbose_name': '"""Участник"""'}), False, 'from django.db import migrations, models\n'), (31, 'django.db.models.AutoField', 'models.AutoField', ([], {'auto_created': '(True)', 'primary_key': '(True)', 'serialize': '(False)', 'verbose_name': '"""ID"""'}), False, 'from django.db import migrations, models\n'), (32, 'django.db.models.CharField', 'models.CharField', ([], {'max_length': '(250)'}), False, 'from django.db import migrations, models\n'), (33, 'django.db.models.CharField', 'models.CharField', ([], {'max_length': '(20)'}), False, 'from django.db import migrations, models\n'), (34, 'django.db.models.CharField', 'models.CharField', ([], {'max_length': '(100)'}), False, 'from django.db import migrations, models\n'), (35, 'django.db.models.DateTimeField', 'models.DateTimeField', ([], {'auto_now_add': '(True)'}), False, 'from django.db import migrations, models\n'), (36, 'django.db.models.DateTimeField', 'models.DateTimeField', ([], {'auto_now': '(True)'}), False, 'from django.db import migrations, models\n'), (37, 'django.db.models.BooleanField', 'models.BooleanField', ([], {'default': '(False)'}), False, 'from django.db import migrations, models\n'), (38, 'django.db.models.CharField', 'models.CharField', ([], {'choices': "[('В обработке', 'В обработке'), ('Заказ собран', 'Заказ собран'), (\n    'Заказ отправлен', 'Заказ отправлен')]", 'default': '"""В обработке"""', 'max_length': '(20)'}), False, 'from django.db import migrations, models\n'), (39, 'django.db.models.ForeignKey', 'models.ForeignKey', ([], {'on_delete': 'django.db.models.deletion.CASCADE', 'related_name': '"""user"""', 'to': 'settings.AUTH_USER_MODEL'}), False, 'from django.db import migrations, models\n'), (49, 'django.db.models.AutoField', 'models.AutoField', ([], {'auto_created': '(True)', 'primary_key': '(True)', 'serialize': '(False)', 'verbose_name': '"""ID"""'}), False, 'from django.db import migrations, models\n'), (50, 'django.db.models.DecimalField', 'models.DecimalField', ([], {'decimal_places': '(2)', 'max_digits': '(10)'}), False, 'from django.db import migrations, models\n'), (51, 'django.db.models.PositiveIntegerField', 'models.PositiveIntegerField', ([], {'default': '(1)'}), False, 'from django.db import migrations, models\n'), (52, 'django.db.models.ForeignKey', 'models.ForeignKey', ([], {'on_delete': 'django.db.models.deletion.CASCADE', 'related_name': '"""items"""', 'to': '"""orders.Order"""'}), False, 'from django.db import migrations, models\n'), (53, 'django.db.models.ForeignKey', 'models.ForeignKey', ([], {'on_delete': 'django.db.models.deletion.CASCADE', 'related_name': '"""order_items"""', 'to': '"""sales_backend.Product"""'}), False, 'from django.db import migrations, models\n'), (54, 'django.db.models.ForeignKey', 'models.ForeignKey', ([], {'on_delete': 'django.db.models.deletion.CASCADE', 'related_name': '"""seller"""', 'to': 'settings.AUTH_USER_MODEL'}), False, 'from django.db import migrations, models\n'), (55, 'django.db.models.ForeignKey', 'models.ForeignKey', ([], {'on_delete': 'django.db.models.deletion.CASCADE', 'related_name': '"""order_users"""', 'to': 'settings.AUTH_USER_MODEL'}), False, 'from django.db import migrations, models\n'), (61, 'django.db.models.AutoField', 'models.AutoField', ([], {'auto_created': '(True)', 'primary_key': '(True)', 'serialize': '(False)', 'verbose_name': '"""ID"""'}), False, 'from django.db import migrations, models\n'), (62, 'django.db.models.TextField', 'models.TextField', ([], {'verbose_name': '"""Сообщение"""'}), False, 'from django.db import migrations, models\n'), (63, 'django.db.models.DateTimeField', 'models.DateTimeField', ([], {'default': 'django.utils.timezone.now', 'verbose_name': '"""Дата сообщения"""'}), False, 'from django.db import migrations, models\n'), (64, 'django.db.models.BooleanField', 'models.BooleanField', ([], {'default': '(False)', 'verbose_name': '"""Прочитано"""'}), False, 'from django.db import migrations, models\n'), (65, 'django.db.models.ForeignKey', 'models.ForeignKey', ([], {'on_delete': 'django.db.models.deletion.CASCADE', 'to': 'settings.AUTH_USER_MODEL', 'verbose_name': '"""Пользователь"""'}), False, 'from django.db import migrations, models\n'), (66, 'django.db.models.ForeignKey', 'models.ForeignKey', ([], {'on_delete': 'django.db.models.deletion.CASCADE', 'to': '"""orders.Chat"""', 'verbose_name': '"""Чат"""'}), False, 'from django.db import migrations, models\n')]