# Generated by Django 2.0.1 on 2018-05-03 13:17

from django.conf import settings
import django.contrib.postgres.fields.jsonb
from django.db import migrations, models
import django.db.models.deletion
import utils.models
import utils.shortcuts


class Migration(migrations.Migration):

    initial = True

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

    operations = [
        migrations.CreateModel(
            name='Course',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('total_student', models.IntegerField(blank=True, default=0)),
                ('title', models.CharField(max_length=64)),
                ('introduction', utils.models.RichTextField()),
                ('picture', models.CharField(default='/public/course/default.png', max_length=256)),
                ('code', models.CharField(max_length=32)),
                ('start_time', models.DateTimeField()),
                ('end_time', models.DateTimeField()),
                ('create_time', models.DateTimeField(auto_now_add=True)),
                ('last_update_time', models.DateTimeField(auto_now=True)),
                ('visible', models.BooleanField(default=True)),
                ('created_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'db_table': 'course',
                'ordering': ('create_time',),
            },
        ),
        migrations.CreateModel(
            name='Course_task',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('title', models.CharField(max_length=64)),
                ('introduction', utils.models.RichTextField()),
                ('visible', models.BooleanField(default=True)),
                ('problem', django.contrib.postgres.fields.jsonb.JSONField(default=list)),
                ('small_problem', django.contrib.postgres.fields.jsonb.JSONField(default=list)),
                ('start_time', models.DateTimeField()),
                ('end_time', models.DateTimeField()),
                ('create_time', models.DateTimeField(auto_now_add=True)),
                ('last_update_time', models.DateTimeField(auto_now=True)),
                ('course', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='course.Course')),
                ('created_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'db_table': 'course_task',
                'ordering': ('create_time',),
            },
        ),
        migrations.CreateModel(
            name='CourseAnnouncement',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('title', models.CharField(max_length=128)),
                ('content', utils.models.RichTextField()),
                ('visible', models.BooleanField(default=True)),
                ('create_time', models.DateTimeField(auto_now_add=True)),
                ('course', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='course.Course')),
                ('created_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'db_table': 'course_announcement',
                'ordering': ('-create_time',),
            },
        ),
        migrations.CreateModel(
            name='CourseSubmission',
            fields=[
                ('id', models.CharField(db_index=True, default=utils.shortcuts.rand_str, max_length=32, primary_key=True, serialize=False)),
                ('create_time', models.DateTimeField(auto_now_add=True)),
                ('user_id', models.IntegerField(db_index=True)),
                ('username', models.CharField(max_length=30)),
                ('code', models.TextField()),
                ('result', models.IntegerField(db_index=True, default=6)),
                ('info', django.contrib.postgres.fields.jsonb.JSONField(default=dict)),
                ('language', models.CharField(max_length=20)),
                ('shared', models.BooleanField(default=False)),
                ('statistic_info', django.contrib.postgres.fields.jsonb.JSONField(default=dict)),
                ('ip', models.CharField(blank=True, max_length=32, null=True)),
                ('problem', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='problem.Problem')),
            ],
            options={
                'db_table': 'course_submission',
                'ordering': ('-create_time',),
            },
        ),
        migrations.CreateModel(
            name='Taskproblem',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('problem', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='problem.Problem')),
                ('task', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='course.Course_task')),
            ],
            options={
                'db_table': 'task_problem',
            },
        ),
        migrations.CreateModel(
            name='TaskSmallproblem',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('smallproblem', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='problem.SmallProblem')),
                ('task', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='course.Course_task')),
            ],
            options={
                'db_table': 'task_small_problem',
            },
        ),
        migrations.CreateModel(
            name='UserCourse',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('create_time', models.DateTimeField(auto_now_add=True, verbose_name='添加时间')),
                ('acm_problem_status', django.contrib.postgres.fields.jsonb.JSONField(default={})),
                ('oi_problem_status', django.contrib.postgres.fields.jsonb.JSONField(default={})),
                ('small_problem_status', django.contrib.postgres.fields.jsonb.JSONField(default={})),
                ('course', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='course.Course', verbose_name='课程')),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='用户')),
            ],
            options={
                'db_table': 'user_course',
                'ordering': ('-create_time',),
            },
        ),
        migrations.AlterUniqueTogether(
            name='course',
            unique_together={('code',)},
        ),
    ]
