# Generated by Django 1.9.8 on 2016-07-25 16:27


from django.db import migrations


def set_study_types(apps, schema_editor):
    Study = apps.get_model("study", "Study")
    Study.objects.filter(study_type=0).update(bioassay=True)
    Study.objects.filter(study_type=1).update(epi=True)
    Study.objects.filter(study_type=4).update(epi_meta=True)
    Study.objects.filter(study_type=2).update(in_vitro=True)


def unset_study_types(apps, schema_editor):
    Study = apps.get_model("study", "Study")
    Study.objects.filter(bioassay=True).update(study_type=0)
    Study.objects.filter(epi=True).update(study_type=1)
    Study.objects.filter(epi_meta=True).update(study_type=4)
    Study.objects.filter(in_vitro=True).update(study_type=2)
    Study.objects.filter(bioassay=False, epi=False, epi_meta=False, in_vitro=False).update(
        study_type=3
    )


class Migration(migrations.Migration):
    dependencies = [
        ("study", "0006_new_study_type"),
    ]

    operations = [
        migrations.RunPython(set_study_types, reverse_code=unset_study_types),
    ]
