# -*- coding: utf-8 -*-
# Generated by Django 1.11.4 on 2019-09-19 03:47
from __future__ import unicode_literals

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

import utils.models


class Migration(migrations.Migration):
    initial = True

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

    operations = [
        migrations.CreateModel(
            name='ACMContestRank',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('user_id', models.CharField(default='', max_length=20, verbose_name='用户编号')),
                ('real_name', models.CharField(default='', max_length=10, verbose_name='真实姓名')),
                ('contest_id', models.IntegerField(default=0, verbose_name='竞赛id')),
                ('submission_number', models.IntegerField(default=0)),
                ('accepted_number', models.IntegerField(default=0)),
                ('total_time', models.IntegerField(default=0)),
                ('submission_info', utils.models.MyJSONField(default=dict)),
            ],
            options={
                'db_table': 'acm_contest_rank',
            },
        ),
        migrations.CreateModel(
            name='Contest',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('display_id', models.PositiveSmallIntegerField(null=True, verbose_name='竞赛显示id')),
                ('title', models.CharField(default='', max_length=32, verbose_name='竞赛标题')),
                ('real_time_rank', models.BooleanField(default=True, verbose_name='实时排名')),
                ('password', models.CharField(default='', max_length=15, null=True)),
                ('rule_type', models.CharField(default='ACM', max_length=3, verbose_name='竞赛类型')),
                ('start_time', models.DateTimeField(verbose_name='开始时间')),
                ('end_time', models.DateTimeField(verbose_name='结束时间')),
                ('create_time', models.DateTimeField(auto_now_add=True, verbose_name='创建时间')),
                ('last_update_time', models.DateTimeField(auto_now=True, verbose_name='最后更新时间')),
                ('scenes', models.CharField(default=0, max_length=5, verbose_name='竞赛场景')),
                ('s_number', models.PositiveSmallIntegerField(default=0, verbose_name='考试人数')),
                ('p_number', models.PositiveSmallIntegerField(default=0, verbose_name='试题数量')),
                ('visible', models.BooleanField(default=True, verbose_name='是否可见')),
                ('allowed_ip_ranges', utils.models.MyJSONField(default=list, verbose_name='默认ip')),
                ('submit_record', models.BooleanField(default=True, verbose_name='是否记录提交')),
                ('languages', utils.models.MyJSONField(default=list, verbose_name='使用语言')),
                ('is_contest', models.BooleanField(default=False, verbose_name='是否为真正竞赛')),
                ('has_problem_list', utils.models.MyJSONField(default=list, verbose_name='已经导入的试题')),
                ('created_by',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL,
                                   verbose_name='创建者')),
            ],
            options={
                'db_table': 'contest',
                'ordering': ('-start_time',),
            },
        ),
        migrations.CreateModel(
            name='ContestAnnouncement',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('title', models.CharField(max_length=20, verbose_name='标题')),
                ('content', utils.models.MyRichTextField()),
                ('visible', models.BooleanField(default=True)),
                ('create_time', models.DateTimeField(auto_now_add=True)),
                ('contest', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='contest.Contest')),
                ('created_by',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'db_table': 'contest_announcement',
                'ordering': ('-create_time',),
            },
        ),
        migrations.CreateModel(
            name='ContestOfGrade',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('grade_id', models.IntegerField(default=0, verbose_name='班级编号')),
                ('contest_id', models.IntegerField(default=0, verbose_name='竞赛编号')),
                ('user_number', models.PositiveSmallIntegerField(default=0, verbose_name='参加人数')),
                ('coverage', models.PositiveSmallIntegerField(default=0, verbose_name='学生参与率')),
                ('create_time', models.DateTimeField(auto_now_add=True, verbose_name='创建时间')),
            ],
            options={
                'db_table': 'contest_grade',
            },
        ),
        migrations.CreateModel(
            name='ContestPartner',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('is_auth', models.BooleanField(default=False, verbose_name='是否认证')),
                ('is_disabled', models.BooleanField(default=False, verbose_name='是否禁用')),
                ('score', models.SmallIntegerField(default=0, verbose_name='成绩')),
                ('last_time', models.DateTimeField(auto_now_add=True)),
                ('contest', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='contest.Contest',
                                              verbose_name='竞赛id')),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL,
                                           verbose_name='参与者id')),
            ],
            options={
                'db_table': 'contest_partner',
            },
        ),
        migrations.CreateModel(
            name='EventFreshHistory',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('uid', models.IntegerField(verbose_name='用户id')),
                ('contest_id', models.IntegerField(verbose_name='竞赛id')),
                ('c_time', models.CharField(max_length=20, verbose_name='刷新时间')),
            ],
            options={
                'db_table': 'event_fresh_his',
            },
        ),
        migrations.CreateModel(
            name='OIContestRank',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('user_id', models.CharField(default='', max_length=20, verbose_name='用户编号')),
                ('real_name', models.CharField(default='', max_length=10, verbose_name='真实姓名')),
                ('contest_id', models.IntegerField(default=0, verbose_name='竞赛id')),
                ('submission_number', models.IntegerField(default=0)),
                ('total_score', models.IntegerField(default=0)),
                ('submission_info', utils.models.MyJSONField(default=dict)),
            ],
            options={
                'db_table': 'oi_contest_rank',
            },
        ),
        migrations.AlterIndexTogether(
            name='eventfreshhistory',
            index_together=set([('uid', 'contest_id')]),
        ),
        migrations.AlterUniqueTogether(
            name='contestofgrade',
            unique_together=set([('contest_id', 'grade_id')]),
        ),
        migrations.AddField(
            model_name='contest',
            name='partner',
            field=models.ManyToManyField(related_name='partner', through='contest.ContestPartner',
                                         to=settings.AUTH_USER_MODEL),
        ),
        migrations.AlterUniqueTogether(
            name='contestpartner',
            unique_together=set([('contest', 'user')]),
        ),
    ]
