"""Seed the wallet Shop applet — Chunk 2 of the wallet expansion sprint.

Locked spec from [[project-wallet-shop-expansion]]: 4 rows total in the
wallet context (Shop atop, Balances + Tokens + Payment beneath); 12 cols
in landscape (full-width row). Mimics the existing wallet applets'
grid_cols=12 / grid_rows=3 shape.

`display_order` is NOT a field on Applet — applet ordering is dictated
by the wallet template's include order in `_applets.html` + the applet
slug alphabetical fallback in `applet_context()`. The template's include
order is set in Chunk 4; this migration just ensures the row exists.
"""
from django.db import migrations


def seed(apps, schema_editor):
    Applet = apps.get_model("applets", "Applet")
    Applet.objects.update_or_create(
        slug="wallet-shop",
        defaults={
            "name": "Shop",
            "context": "wallet",
            "default_visible": True,
            "grid_cols": 12,
            "grid_rows": 3,
        },
    )


def unseed(apps, schema_editor):
    Applet = apps.get_model("applets", "Applet")
    Applet.objects.filter(slug="wallet-shop").delete()


class Migration(migrations.Migration):

    dependencies = [
        ("applets", "0010_rename_my_sign_applet"),
    ]

    operations = [
        migrations.RunPython(seed, unseed),
    ]
