# Generated by Django 5.2.3 on 2026-01-13 20:34

from django.db import migrations


class Migration(migrations.Migration):

    dependencies = [
        ("models", "12547_fix_db_nodevalue_display_value"),
    ]

    def forward(apps, schema_editor):
        DDataType = apps.get_model("models", "DDataType")
        Widget = apps.get_model("models", "Widget")

        widget = Widget(
            widgetid="b1f4d6e2-3c4a-4f5b-8f6d-7e8f9a0b1c2d",
            name="language-widget",
            component="views/components/widgets/language",
            helptext=None,
            datatype="language",
            defaultconfig={
                "defaultValue": None,
                "i18n_properties": ["placeholder"],
                "placeholder": "Select a language",
                "width": "100%",
                "uneditable": False,
            },
        )

        datatype = DDataType(
            datatype="language",
            iconclass="fa fa-language",
            modulename="datatypes.py",
            classname="LanguageDataType",
            defaultconfig=None,
            configcomponent="views/components/datatypes/language",
            configname="language-datatype-config",
            isgeometric=False,
            defaultwidget=widget,
            issearchable=True,
        )
        widget.save()
        datatype.save()

    def reverse(apps, schema_editor):
        DDataType = apps.get_model("models", "DDataType")
        Widget = apps.get_model("models", "Widget")

        DDataType.objects.filter(datatype="language").delete()
        Widget.objects.filter(name="language-widget").delete()

    operations = [
        migrations.RunPython(forward, reverse),
    ]
