# Generated by Django 5.2.3 on 2025-10-22 10:27

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('problem', '0005_remove_spj_fields'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='ProblemSet',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('title', models.TextField(verbose_name='题单标题')),
                ('description', utils.models.RichTextField(verbose_name='题单描述')),
                ('create_time', models.DateTimeField(auto_now_add=True, verbose_name='创建时间')),
                ('last_update_time', models.DateTimeField(auto_now=True, verbose_name='更新时间')),
                ('visible', models.BooleanField(default=True, verbose_name='是否可见')),
                ('is_public', models.BooleanField(default=True, verbose_name='是否公开')),
                ('difficulty', models.TextField(default='Easy', verbose_name='难度等级')),
                ('status', models.TextField(default='active', verbose_name='状态')),
                ('created_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='创建者')),
            ],
            options={
                'verbose_name': '题单',
                'verbose_name_plural': '题单',
                'db_table': 'problemset',
                'ordering': ('-create_time',),
            },
        ),
        migrations.CreateModel(
            name='ProblemSetBadge',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.TextField(verbose_name='奖章名称')),
                ('description', models.TextField(verbose_name='奖章描述')),
                ('icon', models.TextField(verbose_name='奖章图标')),
                ('condition_type', models.TextField(verbose_name='获得条件类型')),
                ('condition_value', models.IntegerField(default=0, verbose_name='条件值')),
                ('level', models.IntegerField(default=1, verbose_name='奖章等级')),
                ('problemset', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='problemset.problemset', verbose_name='题单')),
            ],
            options={
                'verbose_name': '题单奖章',
                'verbose_name_plural': '题单奖章',
                'db_table': 'problemset_badge',
            },
        ),
        migrations.CreateModel(
            name='ProblemSetProblem',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('order', models.IntegerField(default=0, verbose_name='顺序')),
                ('is_required', models.BooleanField(default=True, verbose_name='是否必做')),
                ('score', models.IntegerField(default=0, verbose_name='分值')),
                ('hint', models.TextField(blank=True, null=True, verbose_name='提示')),
                ('problem', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='problem.problem', verbose_name='题目')),
                ('problemset', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='problemset.problemset', verbose_name='题单')),
            ],
            options={
                'verbose_name': '题单题目',
                'verbose_name_plural': '题单题目',
                'db_table': 'problemset_problem',
                'ordering': ('order',),
                'unique_together': {('problemset', 'problem')},
            },
        ),
        migrations.CreateModel(
            name='ProblemSetProgress',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('join_time', models.DateTimeField(auto_now_add=True, verbose_name='加入时间')),
                ('complete_time', models.DateTimeField(blank=True, null=True, verbose_name='完成时间')),
                ('is_completed', models.BooleanField(default=False, verbose_name='是否完成')),
                ('progress_percentage', models.FloatField(default=0.0, verbose_name='完成进度')),
                ('completed_problems_count', models.IntegerField(default=0, verbose_name='已完成题目数')),
                ('total_problems_count', models.IntegerField(default=0, verbose_name='总题目数')),
                ('total_score', models.IntegerField(default=0, verbose_name='总分')),
                ('progress_detail', models.JSONField(default=dict, verbose_name='详细进度')),
                ('problemset', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='problemset.problemset', verbose_name='题单')),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='用户')),
            ],
            options={
                'verbose_name': '题单进度',
                'verbose_name_plural': '题单进度',
                'db_table': 'problemset_progress',
                'unique_together': {('problemset', 'user')},
            },
        ),
        migrations.CreateModel(
            name='UserBadge',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('earned_time', models.DateTimeField(auto_now_add=True, verbose_name='获得时间')),
                ('is_displayed', models.BooleanField(default=False, verbose_name='是否已展示')),
                ('badge', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='problemset.problemsetbadge', verbose_name='奖章')),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='用户')),
            ],
            options={
                'verbose_name': '用户奖章',
                'verbose_name_plural': '用户奖章',
                'db_table': 'user_badge',
                'unique_together': {('user', 'badge')},
            },
        ),
    ]
