# Generated by Django 5.1.5 on 2025-02-12 12:08

from django.db import migrations, models


def migrate_kind_values(apps, schema_editor):
    ServicePath = apps.get_model("cesnet_service_path_plugin", "ServicePath")

    kind_mapping = {
        "Experimentální": "experimental",
        "Páteřní": "core",
        "Zákaznická": "customer",
    }

    for service_path in ServicePath.objects.all():
        if service_path.kind in kind_mapping:
            service_path.kind = kind_mapping[service_path.kind]
            service_path.save()


def reverse_kind_values(apps, schema_editor):
    ServicePath = apps.get_model("cesnet_service_path_plugin", "ServicePath")

    reverse_mapping = {
        "experimental": "Experimentální",
        "core": "Páteřní",
        "customer": "Zákaznická",
    }

    for service_path in ServicePath.objects.all():
        if service_path.kind in reverse_mapping:
            service_path.kind = reverse_mapping[service_path.kind]
            service_path.save()


class Migration(migrations.Migration):
    dependencies = [
        ("cesnet_service_path_plugin", "0022_remove_field_state_from_servicepath"),
    ]

    operations = [
        migrations.AlterField(
            model_name="servicepath",
            name="kind",
            field=models.CharField(default="core", max_length=30),
        ),
        migrations.RunPython(migrate_kind_values, reverse_code=reverse_kind_values),
    ]
