# Generated by Django 3.2.20 on 2024-04-24 09:05

from django.db import migrations


def drop_past_reviewer_setting(apps, schema_editor):
    Setting = apps.get_model("core", "Setting")
    Setting.objects.filter(
        name="display_past_reviewers",
    ).delete()


def create_past_reviewer_setting(apps, schema_editor):
    # Recreate the setting enough that it won't bork anything in the event
    # the migration needs to be reversed.
    Setting = apps.get_model("core", "Setting")
    SettingGroup = apps.get_model("core", "SettingGroup")
    SettingValue = apps.get_model("core", "SettingValue")
    group = SettingGroup.objects.get(name="general")
    setting = Setting.objects.create(
        group=group,
        name="display_past_reviewers",
        types="boolean",
        pretty_name="Display List of Reviewers from Past Review Rounds",
        description="When this setting is enabled the review assignment page "
        "will show a table of reviewers who have completed a "
        "review in past review rounds.",
    )
    SettingValue.objects.create(
        setting=setting,
        value="",
    )


class Migration(migrations.Migration):
    dependencies = [
        ("core", "0088_merge_20240327_1910"),
    ]

    operations = [
        migrations.RunPython(
            drop_past_reviewer_setting, reverse_code=create_past_reviewer_setting
        ),
    ]
