# -*- coding: utf-8 -*-
# Generated by Django 1.9.5 on 2016-07-19 13:43
from __future__ import unicode_literals

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


def add_training_requirements(apps, schema_editor):
    TrainingRequirement = apps.get_model('workshops', 'TrainingRequirement')
    TrainingRequirement.objects.get_or_create(name='Training', event_required=True)
    TrainingRequirement.objects.get_or_create(name='DC Homework', url_required=True)
    TrainingRequirement.objects.get_or_create(name='SWC Homework', url_required=True)
    TrainingRequirement.objects.get_or_create(name='Discussion')
    TrainingRequirement.objects.get_or_create(name='DC Demo')
    TrainingRequirement.objects.get_or_create(name='SWC Demo')


class Migration(migrations.Migration):

    dependencies = [
        ('workshops', '0113_add_tag_cancelled'),
    ]

    operations = [
        migrations.CreateModel(
            name='TrainingProgress',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('last_updated_at', models.DateTimeField(auto_now=True, null=True)),
                ('state', models.CharField(choices=[('n', 'Not evaluated yet'), ('f', 'Failed'), ('p', 'Passed')], default='p', max_length=1)),
                ('discarded', models.BooleanField(default=False, help_text='Check when the trainee has gone silent or passed their training deadline. Discarded items are not permanently deleted permanently from AMY. If you want to remove this record, click red "delete" button.', verbose_name='Discarded')),
                ('url', models.URLField(blank=True, null=True)),
                ('notes', models.TextField(blank=True)),
                ('evaluated_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='+', to=settings.AUTH_USER_MODEL)),
                ('event', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='workshops.Event', verbose_name='Training')),
            ],
            options={
                'ordering': ['created_at'],
            },
        ),
        migrations.CreateModel(
            name='TrainingRequirement',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=40)),
                ('url_required', models.BooleanField(default=False)),
                ('event_required', models.BooleanField(default=False)),
            ],
            options={
                'ordering': ['name'],
            },
        ),
        migrations.AddField(
            model_name='trainingrequest',
            name='person',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='Matched Trainee'),
        ),
        migrations.AddField(
            model_name='trainingrequest',
            name='state',
            field=models.CharField(choices=[('p', 'Pending'), ('a', 'Accepted'), ('d', 'Discarded')], default='p', max_length=1),
        ),
        migrations.AddField(
            model_name='trainingprogress',
            name='requirement',
            field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='workshops.TrainingRequirement', verbose_name='Type'),
        ),
        migrations.AddField(
            model_name='trainingprogress',
            name='trainee',
            field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL),
        ),
        migrations.RunPython(code=add_training_requirements,
                             reverse_code=migrations.RunPython.noop),
    ]
