# Generated by Django 2.2.17 on 2021-04-26 13:29

from django.db import migrations, models


def move_failed_to_ask_to_repeat(apps, schema_editor):
    """
    As per https://github.com/carpentries/amy/issues/1808 we want to move all currently "Failed" statuses to "Asked to repeat"
    """
    TrainingProgress = apps.get_model('workshops', 'TrainingProgress')
    TrainingProgress.objects.filter(state="f").update(state="a")

def undo_move_failed_to_ask_to_repeat(apps, schema_editor):
    TrainingProgress = apps.get_model('workshops', 'TrainingProgress')
    TrainingProgress.objects.filter(state="a").update(state="f")


class Migration(migrations.Migration):

    dependencies = [
        ('workshops', '0240_auto_20210402_1917'),
    ]

    operations = [
        migrations.AlterField(
            model_name='trainingprogress',
            name='state',
            field=models.CharField(choices=[('n', 'Not evaluated yet'), ('f', 'Failed'), ('p', 'Passed'), ('a', 'Asked to repeat')], default='p', max_length=1),
        ),
        migrations.RunPython(move_failed_to_ask_to_repeat, undo_move_failed_to_ask_to_repeat),
    ]
