# Generated by Django 3.2.5 on 2021-08-26 10:41

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


class Migration(migrations.Migration):

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

    operations = [
        migrations.CreateModel(
            name='Evaluation',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='created at')),
                ('modified_at', models.DateTimeField(auto_now=True, verbose_name='modified at')),
                ('mark', models.PositiveSmallIntegerField(blank=True, default=5, help_text='Mark which user has set.', null=True, validators=[django.core.validators.MinValueValidator(1), django.core.validators.MaxValueValidator(10)], verbose_name='Mark')),
                ('comment', ckeditor.fields.RichTextField(help_text='Comment on the evaluation of the solution.', max_length=8000, verbose_name='Comment')),
                ('owner', models.ForeignKey(help_text='User who evaluate this solution.', on_delete=django.db.models.deletion.CASCADE, related_name='owner', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'verbose_name': 'Evaluation info',
                'verbose_name_plural': 'Evaluation info',
            },
        ),
        migrations.AlterModelOptions(
            name='topic',
            options={'ordering': ('reading_date',), 'verbose_name': 'Topic', 'verbose_name_plural': 'Topics'},
        ),
        migrations.AddField(
            model_name='course',
            name='default_speaker',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='lead_courses', to=settings.AUTH_USER_MODEL, verbose_name='Default speaker'),
        ),
        migrations.AddField(
            model_name='task',
            name='jira_tag',
            field=models.CharField(blank=True, max_length=15, verbose_name='Jira tag'),
        ),
        migrations.AddField(
            model_name='topic',
            name='reading_date',
            field=models.DateField(auto_now_add=True, null=True, verbose_name='Reading date'),
        ),
        migrations.AlterField(
            model_name='attachment',
            name='file',
            field=models.FileField(upload_to='solutions/files/', verbose_name='File'),
        ),
        migrations.AlterField(
            model_name='chapter',
            name='finish_date',
            field=models.DateField(verbose_name='Finish date'),
        ),
        migrations.AlterField(
            model_name='chapter',
            name='start_date',
            field=models.DateField(verbose_name='Start date'),
        ),
        migrations.AlterField(
            model_name='comment',
            name='user',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='User'),
        ),
        migrations.AlterField(
            model_name='course',
            name='finish_date',
            field=models.DateField(verbose_name='Finish date'),
        ),
        migrations.AlterField(
            model_name='course',
            name='start_date',
            field=models.DateField(verbose_name='Start date'),
        ),
        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, verbose_name='created at')),
                ('modified_at', models.DateTimeField(auto_now=True, verbose_name='modified at')),
                ('solution_description', ckeditor.fields.RichTextField(max_length=8000, verbose_name='Description of solution')),
                ('attachment', models.FileField(blank=True, null=True, upload_to='solutions/files/', verbose_name='Attachment')),
                ('evaluations', models.ManyToManyField(blank=True, through='courses.Evaluation', to=settings.AUTH_USER_MODEL)),
                ('owner', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='solutions', to=settings.AUTH_USER_MODEL)),
                ('task', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='solutions', to='courses.task')),
            ],
            options={
                'verbose_name': 'Solution',
                'verbose_name_plural': 'Solutions',
                'unique_together': {('task', 'owner')},
            },
        ),
        migrations.AddField(
            model_name='evaluation',
            name='solution',
            field=models.ForeignKey(help_text='Solution that is being evaluated.', on_delete=django.db.models.deletion.CASCADE, related_name='evaluated_solution', to='courses.solution'),
        ),
        migrations.AddField(
            model_name='task',
            name='solution',
            field=models.ManyToManyField(through='courses.Solution', to=settings.AUTH_USER_MODEL, verbose_name='solution'),
        ),
        migrations.AlterUniqueTogether(
            name='evaluation',
            unique_together={('solution', 'owner')},
        ),
    ]
