# Generated by Django 5.2.9 on 2025-12-23 15:59

from django.db import migrations


class Migration(migrations.Migration):

    @staticmethod
    def create_tinywiki_sections(apps, schema_editor):
        from tinywiki.models import SidebarSection, SidebarEntry

        data = [
            {
                "title": "TinyWiki Pages",
                "is_visible": True,
                "priority": 1000,
                "items": [
                    {
                        "title": "BBCode Guide",
                        "is_visible": True,
                        "priority": 100,
                        "wiki_slug": "tw-bbcode",
                    },
                    {
                        "title": "Markdown Guide",
                        "is_visible": True,
                        "priority": 90,
                        "wiki_slug": "tw-markdown"
                    },
                    {
                        "title": "TinyWiki License",
                        "is_visible": True,
                        "priority": 80,
                        "wiki_slug": "tw-license"
                    },
                    {
                        "title": "Bootstrap License",
                        "is_visible": True,
                        "priority": 70,
                        "wiki_slug": "tw-bootstrap-license"
                    },
                ]
            },
            {
                "title": "TinyWiki Seiten",
                "is_visible": False,
                "priority": 1000,
                "items": [
                    {
                        "title": "BBCode Anleitung",
                        "is_visible": True,
                        "priority": 100,
                        "wiki_slug": "tw-de-bbcode",
                    },
                    {
                        "title": "Markdown Anleitung",
                        "is_visible": True,
                        "priority": 90,
                        "wiki_slug": "tw-de-markdown"
                    },
                    {
                        "title": "TinyWiki Lizenz (EN)",
                        "is_visible": True,
                        "priority": 80,
                        "wiki_slug": "tw-license"
                    },
                    {
                        "title": "Bootstrap License (EN)",
                        "is_visible": True,
                        "priority": 70,
                        "wiki_slug": "tw-bootstrap-license"
                    },
                ]
            },
        ]

        for sect_spec in data:
            if 'items' in sect_spec:
                items = sect_spec.pop('items')
            else:
                items = []

            section = SidebarSection.objects.create(**sect_spec)
            for item_spec in items:
                SidebarEntry.objects.create(section=section, **item_spec)

    dependencies = [
        ('tinywiki', '0002_initial_data'),
    ]

    operations = [
        migrations.RunPython(create_tinywiki_sections),
    ]
