# Generated by Django 3.1.4 on 2020-12-29 15:19

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ('contenttypes', '0002_remove_content_type_name'),
    ]

    operations = [
        migrations.CreateModel(
            name='AbstractSabotage',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('start_time', models.DateTimeField(help_text='Начало саботажа')),
                ('finish_time', models.DateTimeField(help_text='Конец саботажа')),
                ('score', models.IntegerField(help_text='Баллы саботажа')),
            ],
            options={
                'abstract': False,
                'base_manager_name': 'objects',
            },
        ),
        migrations.CreateModel(
            name='Contest',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(help_text='Имя контеста', max_length=100)),
                ('start_time', models.DateTimeField(help_text='Начало контеста')),
                ('finish_time', models.DateTimeField(help_text='Конец контеста')),
            ],
        ),
        migrations.CreateModel(
            name='Problem',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('statement', models.TextField(help_text='Условие задачи')),
                ('input_format', models.TextField(help_text='Формат входных данных')),
                ('output_format', models.TextField(help_text='Формат выходных данных')),
                ('correct_regex', models.CharField(help_text='Регулярное выражение для правильного ответа. Без ^ и $', max_length=500)),
                ('max_score', models.IntegerField(help_text='Максимальное количество очков за задачу', validators=[django.core.validators.MinValueValidator(1)])),
            ],
        ),
        migrations.CreateModel(
            name='Solution',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created_at', models.DateTimeField(auto_now_add=True, help_text='Время отправки ответа')),
                ('answer', models.TextField(blank=True, help_text='Ответ')),
                ('is_correct', models.BooleanField()),
                ('score', models.IntegerField(help_text='Баллы за ответ')),
                ('problem', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='solutions', to='contests.problem')),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='solutions', to=settings.AUTH_USER_MODEL)),
            ],
        ),
        migrations.CreateModel(
            name='SabotageSolution',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('answer', models.TextField(blank=True, help_text='Ответ')),
                ('is_correct', models.BooleanField()),
                ('contest', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='sabotage_solutions', to='contests.contest')),
                ('sabotage', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='solutions', to='contests.abstractsabotage')),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='sabotage_solutions', to=settings.AUTH_USER_MODEL)),
            ],
        ),
        migrations.AddField(
            model_name='contest',
            name='problems',
            field=models.ManyToManyField(blank=True, help_text='Задачи контеста', related_name='contests', to='contests.Problem'),
        ),
        migrations.AddField(
            model_name='contest',
            name='users',
            field=models.ManyToManyField(blank=True, help_text='Участники контеста', related_name='contests', to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='abstractsabotage',
            name='contest',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='sabotages', to='contests.contest'),
        ),
        migrations.AddField(
            model_name='abstractsabotage',
            name='polymorphic_ctype',
            field=models.ForeignKey(editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='polymorphic_contests.abstractsabotage_set+', to='contenttypes.contenttype'),
        ),
        migrations.AddField(
            model_name='abstractsabotage',
            name='user',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='own_sabotages', to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='abstractsabotage',
            name='users',
            field=models.ManyToManyField(related_name='sabotages', to=settings.AUTH_USER_MODEL),
        ),
        migrations.CreateModel(
            name='CloseSubmissionSabotage',
            fields=[
                ('abstractsabotage_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='contests.abstractsabotage')),
                ('problem', models.ForeignKey(help_text='Какую задачу закрыть', on_delete=django.db.models.deletion.CASCADE, related_name='close_submission_sabotages', to='contests.problem')),
            ],
            options={
                'abstract': False,
                'base_manager_name': 'objects',
            },
            bases=('contests.abstractsabotage',),
        ),
    ]
