# Generated by Django 3.2.6 on 2021-10-06 21:33

from django.db import migrations, models

from clubs.models import ApplicationSubmission


def reassign_status(apps, schema_editor):
    submissions = ApplicationSubmission.objects.all()
    for submission in submissions:
        if submission.status == 1:
            pass
        elif submission.status == 2:
            submission.status = ApplicationSubmission.PENDING
        elif submission.status == 3:
            submission.status = ApplicationSubmission.PENDING
        elif submission.status == 4:
            pass
        elif submission.status == 5:
            submission.status = ApplicationSubmission.REJECTED_AFTER_WRITTEN
        submission.save()


class Migration(migrations.Migration):

    dependencies = [
        ("clubs", "0087_questionanswer_users_liked"),
    ]

    operations = [
        migrations.AlterField(
            model_name="applicationsubmission",
            name="status",
            field=models.IntegerField(
                choices=[
                    (1, "Pending"),
                    (2, "Rejected after interview(s)"),
                    (3, "Rejected after written application"),
                    (4, "Accepted"),
                ],
                default=1,
            ),
        ),
        migrations.RunPython(reassign_status),
    ]
