# Generated by Django 5.0.4 on 2024-04-26 08:14

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('auction', '0001_initial'),
        ('clicks', '0001_initial'),
        ('contenttypes', '0002_remove_content_type_name'),
        ('misc', '0001_initial'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='Transaction',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('date', models.DateTimeField(auto_now_add=True, verbose_name='Дата и время')),
                ('value', models.DecimalField(decimal_places=5, max_digits=105, verbose_name='Значение')),
                ('polymorphic_ctype', models.ForeignKey(editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='polymorphic_%(app_label)s.%(class)s_set+', to='contenttypes.contenttype')),
            ],
            options={
                'verbose_name': 'Транзакция',
                'verbose_name_plural': 'Транзакции',
            },
        ),
        migrations.CreateModel(
            name='TGUser',
            fields=[
                ('tg_id', models.PositiveBigIntegerField(primary_key=True, serialize=False, verbose_name='Telegram ID')),
                ('username', models.CharField(max_length=250, verbose_name='Telegram username')),
                ('avatar', models.FileField(blank=True, null=True, upload_to='users/', verbose_name='Аватарка')),
                ('points', models.DecimalField(decimal_places=2, default=0, max_digits=102, verbose_name='Баллы')),
                ('referral_storage', models.DecimalField(decimal_places=5, default=0, max_digits=102, verbose_name='Реферальное хранилище')),
                ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='Дата и время создания')),
                ('referred_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='referrees', to='users.tguser', verbose_name='Кем был приглашен')),
                ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='tg_user', to=settings.AUTH_USER_MODEL, verbose_name='Пользователь')),
            ],
            options={
                'verbose_name': 'ТГ-пользователь',
                'verbose_name_plural': 'ТГ-пользователи',
            },
        ),
        migrations.CreateModel(
            name='ReferralTransaction',
            fields=[
                ('transaction_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='users.transaction')),
            ],
            options={
                'verbose_name': 'Реферальная транзакция',
                'verbose_name_plural': 'Реферальные транзакции',
            },
            bases=('users.transaction',),
        ),
        migrations.CreateModel(
            name='MailingList',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=250, verbose_name='Название')),
                ('time', models.DateTimeField(verbose_name='Дата и время публикации')),
                ('text', models.TextField(verbose_name='Текст публикации')),
                ('media', models.FileField(upload_to='mailing/', verbose_name='Вложение')),
                ('status', models.CharField(choices=[('1', 'Ожидание'), ('2', 'В очереди'), ('3', 'В обработке'), ('4', 'Окончена с ошибками'), ('5', 'Завершена')], default='1', max_length=1, verbose_name='Статус')),
                ('main_button', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='mailing_lists_for_main_button', to='misc.button', verbose_name='Кнопка')),
                ('webapp_button', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='mailing_lists_for_webapp_button', to='misc.button', verbose_name='Кнопка с веб-аппом')),
            ],
            options={
                'verbose_name': 'Рассылка',
                'verbose_name_plural': 'Рассылки',
            },
        ),
        migrations.AddField(
            model_name='transaction',
            name='user',
            field=models.ForeignKey(db_constraint=False, on_delete=django.db.models.deletion.DO_NOTHING, related_name='transactions', to='users.tguser', verbose_name='Пользователь'),
        ),
        migrations.CreateModel(
            name='MailingListReceiverInfo',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('sent', models.BooleanField(default=False, verbose_name='Отправлена ли')),
                ('clicked', models.BooleanField(default=False, verbose_name='Нажата ли')),
                ('mailing_list', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='mailing_list_receiver_infos', to='users.mailinglist', verbose_name='Рассылка')),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='mailing_list_receiver_infos', to='users.tguser', verbose_name='Пользователь')),
            ],
            options={
                'verbose_name': 'Информация о получателе рассылки',
                'verbose_name_plural': 'Информация о получателях рассылки',
            },
        ),
        migrations.AddField(
            model_name='mailinglist',
            name='users',
            field=models.ManyToManyField(related_name='mailing_lists', through='users.MailingListReceiverInfo', to='users.tguser', verbose_name='Пользователи'),
        ),
        migrations.CreateModel(
            name='BetTransaction',
            fields=[
                ('transaction_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='users.transaction')),
                ('bet', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='transaction', to='auction.bet', verbose_name='Ставка')),
                ('refund_to', models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='refunded_by', to='users.bettransaction', verbose_name='Какую транзакцию отменяет')),
            ],
            options={
                'verbose_name': 'Транзакция за ставку',
                'verbose_name_plural': 'Транзакции за ставки',
            },
            bases=('users.transaction',),
        ),
        migrations.CreateModel(
            name='ClickTransaction',
            fields=[
                ('transaction_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='users.transaction')),
                ('click', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='transaction', to='clicks.click', verbose_name='Клик')),
            ],
            options={
                'verbose_name': 'Транзакция за клик',
                'verbose_name_plural': 'Транзакции за клики',
            },
            bases=('users.transaction',),
        ),
        migrations.CreateModel(
            name='CommissionTransaction',
            fields=[
                ('transaction_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='users.transaction')),
                ('parent_transaction', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='commission', to='users.bettransaction', verbose_name='Родительская транзакция')),
            ],
            options={
                'verbose_name': 'Комиссионная транзакция',
                'verbose_name_plural': 'Комиссионные транзакции',
            },
            bases=('users.transaction',),
        ),
        migrations.AddConstraint(
            model_name='tguser',
            constraint=models.UniqueConstraint(fields=('tg_id',), name='unique_tg_id'),
        ),
    ]
