# Generated by Django 3.2.12 on 2022-04-12 13:53

from django.db import migrations, models


def flag_top_priority_barriertag(apps, schema_editor):
    # flag BarrierTag with title 'TOP-PRIORITY BARRIER' as indicating Top Pririty
    BarrierTag = apps.get_model("metadata", "BarrierTag")
    BarrierTag.objects.filter(title="TOP 100 PRIORITY BARRIER").update(
        is_top_priority_tag=True
    )


def reverse_flag_top_priority_barriertag(apps, schema_editor):
    # reverse BarrierTag with title 'TOP 100 PRIORITY BARRIER' from indicating Top Prority
    BarrierTag = apps.get_model("metadata", "BarrierTag")
    BarrierTag.objects.filter(title="TOP 100 PRIORITY BARRIER").update(
        is_top_priority_tag=False
    )


class Migration(migrations.Migration):

    dependencies = [
        ("metadata", "0023_rename_top_priority_barrier"),
    ]

    operations = [
        migrations.AddField(
            model_name="barriertag",
            name="is_top_priority_tag",
            field=models.BooleanField(
                default=False,
                help_text="Denotes that this tag labels a barrier as Top Priority",
            ),
        ),
        migrations.RunPython(
            flag_top_priority_barriertag,
            reverse_code=reverse_flag_top_priority_barriertag,
        ),
    ]
