# Generated by Django 2.0.9 on 2018-11-15 19:36

from django.db import migrations

from concordia.models import TranscriptionStatus


def split_edit_statuses(apps, schema_editor):
    Transcription = apps.get_model("concordia", "Transcription")
    Asset = apps.get_model("concordia", "Asset")

    Asset.objects.filter(
        pk__in=Transcription.objects.values("asset_id"), transcription_status="edit"
    ).update(transcription_status=TranscriptionStatus.IN_PROGRESS)
    Asset.objects.filter(transcription_status="edit").update(
        transcription_status=TranscriptionStatus.NOT_STARTED
    )


class Migration(migrations.Migration):

    dependencies = [("concordia", "0014_auto_20181115_1411")]

    operations = [migrations.RunPython(split_edit_statuses)]
