# Generated by Django 2.2.9 on 2020-02-04 02:08

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('problem', '__first__'),
        ('account', '0001_initial'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='Activity',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('title', models.CharField(max_length=192, unique=True, verbose_name='标题')),
                ('description', models.TextField(blank=True, verbose_name='内容')),
                ('create_time', models.DateTimeField(auto_now_add=True)),
                ('update_time', models.DateTimeField(auto_now_add=True)),
                ('register_start_time', models.DateTimeField(blank=True, verbose_name='开始注册时间')),
                ('register_end_time', models.DateTimeField(blank=True, verbose_name='结束注册时间')),
                ('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
            ],
        ),
        migrations.CreateModel(
            name='Contest',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('title', models.CharField(max_length=192, verbose_name='标题')),
                ('description', models.TextField(blank=True, verbose_name='描述')),
                ('allowed_lang', models.CharField(default='c,cc14,cc17,cpp,java,pas,py2,pypy,pypy3,python,text', max_length=192, verbose_name='允许语言')),
                ('contest_type', models.IntegerField(choices=[(0, '常规比赛'), (1, '作业')], default=0)),
                ('start_time', models.DateTimeField(blank=True, default=django.utils.timezone.now, null=True, verbose_name='开始时间')),
                ('end_time', models.DateTimeField(blank=True, default=django.utils.timezone.now, null=True, verbose_name='结束时间')),
                ('create_time', models.DateTimeField(auto_now_add=True, verbose_name='创建时间')),
                ('standings_update_time', models.DateTimeField(blank=True, null=True, verbose_name='榜单更新时间')),
                ('freeze', models.BooleanField(default=False, verbose_name='是否封榜')),
                ('freeze_time', models.DateTimeField(blank=True, null=True, verbose_name='封榜时间')),
                ('scoring_method', models.CharField(choices=[('acm', 'ACM 赛制'), ('oi', 'OI 赛制'), ('cf', 'School of Data Analysis (SDA) 赛制 (Codeforces...)'), ('tcmtime', 'TCM/TIME 赛制 (GCJ...)')], default='acm', max_length=10, verbose_name='计分规则')),
                ('run_tests_during_contest', models.CharField(choices=[('all', '所有测试点'), ('pretest', '只测试 Pretests'), ('sample', '只测试样例'), ('none', '不作测试')], default='all', max_length=10, verbose_name='比赛过程中对代码进行评测')),
                ('allow_code_share', models.IntegerField(choices=[(0, '不允许'), (1, '代码在赛后对 AC 用户公开（默认）'), (2, '代码在赛后完全公开'), (3, '代码在比赛过程中对 AC 用户公开')], default=1, verbose_name='允许代码共享')),
                ('last_counts', models.BooleanField(default=False, verbose_name='认为最后一次提交有效（默认使用成绩最好的）')),
                ('penalty_counts', models.PositiveIntegerField(default=1200, verbose_name='错误提交罚时（秒）')),
                ('standings_without_problem', models.BooleanField(default=False, verbose_name='排行榜上不显示具体题目的通过情况')),
                ('case_public', models.PositiveIntegerField(choices=[(0, '不允许'), (1, '评测报告有偿公开'), (2, '评测报告总是开放')], default=0)),
                ('system_tested', models.BooleanField(default=False, verbose_name='系统测试准备就绪')),
                ('access_level', models.PositiveIntegerField(choices=[(0, '仅比赛管理员可见'), (10, '仅受邀用户可见，赛后题目不公开'), (20, '仅受邀用户可见，赛后题目直接公开'), (30, '公开，需要比赛前注册'), (40, '公开')], default=0, verbose_name='访问控制')),
                ('common_status_access_level', models.IntegerField(choices=[(-10, '不可见'), (0, '默认'), (10, '总是可见')], default=0, verbose_name='所有提交和榜单的访问控制')),
                ('ip_sensitive', models.BooleanField(default=False, verbose_name='首次登录绑定 IP')),
                ('analysis_blog_id', models.IntegerField(default=0, verbose_name='题解博客 ID')),
                ('pdf_statement', models.FileField(blank=True, null=True, upload_to='contest_statements/%Y%m%d/', verbose_name='PDF 题面')),
                ('authors', models.ManyToManyField(related_name='written_contests', to=settings.AUTH_USER_MODEL)),
                ('managers', models.ManyToManyField(related_name='managing_contests', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'ordering': ['-pk'],
            },
        ),
        migrations.CreateModel(
            name='ContestProblemPlag',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('fingerprint', models.CharField(max_length=100)),
                ('status', models.IntegerField(choices=[(-1, 'Pending'), (0, 'Ready'), (1, 'Failed')])),
                ('identifier', models.CharField(blank=True, max_length=20)),
                ('language', models.CharField(default='c/c++', max_length=20)),
                ('keep_match', models.PositiveIntegerField(default=20)),
                ('create_time', models.DateTimeField(auto_now_add=True)),
                ('update_time', models.DateTimeField(auto_now=True)),
                ('contest', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='contest.Contest')),
            ],
        ),
        migrations.CreateModel(
            name='ContestProblem',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('identifier', models.CharField(max_length=12)),
                ('weight', models.IntegerField(default=100)),
                ('ac_user_count', models.PositiveIntegerField(default=0)),
                ('total_user_count', models.PositiveIntegerField(default=0)),
                ('ac_count', models.PositiveIntegerField(default=0)),
                ('total_count', models.PositiveIntegerField(default=0)),
                ('first_yes_time', models.DurationField(blank=True, null=True)),
                ('first_yes_by', models.PositiveIntegerField(blank=True, null=True)),
                ('max_score', models.FloatField(default=0)),
                ('avg_score', models.FloatField(default=0)),
                ('contest', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='contest.Contest')),
                ('problem', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='problem.Problem')),
            ],
            options={
                'ordering': ['identifier'],
                'unique_together': {('problem', 'contest')},
            },
        ),
        migrations.CreateModel(
            name='ContestParticipant',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('star', models.BooleanField(default=False)),
                ('comment', models.TextField(blank=True)),
                ('hidden_comment', models.TextField(blank=True)),
                ('score', models.IntegerField(default=0)),
                ('penalty', models.BigIntegerField(default=0)),
                ('detail_raw', models.TextField(blank=True)),
                ('is_disabled', models.BooleanField(default=False)),
                ('ip_address', models.GenericIPAddressField(blank=True, null=True)),
                ('join_time', models.DateTimeField(blank=True, null=True)),
                ('is_confirmed', models.BooleanField(default=False)),
                ('contest', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='contest.Contest')),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'ordering': ('-is_confirmed', '-score', 'penalty', 'star'),
                'unique_together': {('user', 'contest')},
            },
        ),
        migrations.CreateModel(
            name='ContestClarification',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('text', models.TextField(blank=True)),
                ('time', models.DateTimeField(auto_now=True)),
                ('important', models.BooleanField(default=False)),
                ('answer', models.TextField(blank=True)),
                ('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
                ('contest', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='contest.Contest')),
            ],
            options={
                'ordering': ['-time'],
            },
        ),
        migrations.AddField(
            model_name='contest',
            name='participants',
            field=models.ManyToManyField(related_name='contests', through='contest.ContestParticipant', to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='contest',
            name='problems',
            field=models.ManyToManyField(through='contest.ContestProblem', to='problem.Problem'),
        ),
        migrations.AddField(
            model_name='contest',
            name='volunteers',
            field=models.ManyToManyField(related_name='volunteering_contests', to=settings.AUTH_USER_MODEL),
        ),
        migrations.CreateModel(
            name='ActivityParticipant',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('real_name', models.CharField(max_length=30, verbose_name='真实姓名')),
                ('student_id', models.CharField(max_length=30, verbose_name='学号')),
                ('email', models.CharField(max_length=192, validators=[django.core.validators.EmailValidator()], verbose_name='电子邮箱')),
                ('phone', models.CharField(blank=True, max_length=30, verbose_name='电话')),
                ('major', models.CharField(blank=True, choices=[('art', '艺术'), ('accounting', '会计'), ('business', '商业'), ('business_admin', '工商管理'), ('chemistry', '化学'), ('communication', '通信'), ('ce', '计算机工程'), ('cs', '计算机科学'), ('economics', '经济'), ('education', '教育'), ('ee', '电子工程'), ('finance', '金融'), ('geology', '地理'), ('interaction', '人机交互'), ('it', '信息技术'), ('life', '生命科学'), ('mechanics', '机械'), ('linguistics', '语言学'), ('literature', '文学'), ('math', '数学'), ('se', '软件工程'), ('philosophy', '哲学'), ('physics', '物理'), ('politics', '政治学'), ('psycho', '心理学'), ('social', '社会学'), ('translation', '翻译'), ('others', '其他')], max_length=30, verbose_name='专业')),
                ('gender', models.CharField(blank=True, choices=[('m', '男'), ('f', '女'), ('d', '拒绝回答')], max_length=5, verbose_name='性别')),
                ('graduate_year', models.IntegerField(blank=True, null=True, verbose_name='毕业年份')),
                ('is_deleted', models.BooleanField(default=False, verbose_name='已删除')),
                ('is_confirmed', models.BooleanField(default=False, verbose_name='已确认')),
                ('activity', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='contest.Activity')),
                ('school', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='account.School', verbose_name='学校')),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'unique_together': {('user', 'activity')},
            },
        ),
        migrations.AddField(
            model_name='activity',
            name='participants',
            field=models.ManyToManyField(related_name='activities', through='contest.ActivityParticipant', to=settings.AUTH_USER_MODEL),
        ),
        migrations.CreateModel(
            name='ContestUserRating',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('rating', models.IntegerField(default=1500)),
                ('solved', models.IntegerField()),
                ('rank', models.IntegerField()),
                ('modified', models.DateTimeField()),
                ('contest', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='contest.Contest')),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'ordering': ['-modified'],
                'unique_together': {('contest', 'user')},
            },
        ),
        migrations.CreateModel(
            name='ContestInvitation',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('star', models.BooleanField(default=False)),
                ('code', models.CharField(max_length=24)),
                ('comment', models.TextField(blank=True)),
                ('contest', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='contest.Contest')),
            ],
            options={
                'ordering': ['-pk'],
                'unique_together': {('contest', 'code')},
            },
        ),
    ]
