# Generated by Django 3.2.6 on 2021-09-24 12:24

from django.db import migrations


def copy_app_numbers(apps, schema_editor):
    Request = apps.get_model("evaluations", "request")
    for request in Request.objects.exclude(application_number=""):
        request.reference = request.application_number
        request.save()

    Evaluation = apps.get_model("evaluations", "Evaluation")
    for evaluation in Evaluation.objects.select_related("request"):
        if evaluation.application_number:
            evaluation.reference = evaluation.application_number
        elif evaluation.request and evaluation.request.application_number:
            evaluation.reference = evaluation.request.application_number
        evaluation.save()


class Migration(migrations.Migration):

    dependencies = [
        ("evaluations", "0026_alter_evaluation_request"),
    ]

    operations = [
        migrations.RunPython(copy_app_numbers, migrations.RunPython.noop),
    ]

# Generated by Django 3.2.6 on 2021-09-24 12:24

from django.db import migrations


def copy_app_numbers(apps, schema_editor):
    Request = apps.get_model("evaluations", "request")
    for request in Request.objects.exclude(application_number=""):
        request.reference = request.application_number
        request.save()

    Evaluation = apps.get_model("evaluations", "Evaluation")
    for evaluation in Evaluation.objects.select_related("request"):
        if evaluation.application_number:
            evaluation.reference = evaluation.application_number
        elif evaluation.request and evaluation.request.application_number:
            evaluation.reference = evaluation.request.application_number
        evaluation.save()


class Migration(migrations.Migration):

    dependencies = [
        ("evaluations", "0026_alter_evaluation_request"),
    ]

    operations = [
        migrations.RunPython(copy_app_numbers, migrations.RunPython.noop),
    ]

# Generated by Django 3.2.6 on 2021-09-24 12:24