# Generated by Django 5.2.8 on 2025-12-06 23:52

import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ("auth", "0012_alter_user_first_name_max_length"),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name="WidgetZone",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("is_seed_data", models.BooleanField(default=False, editable=False)),
                ("is_user_data", models.BooleanField(default=False, editable=False)),
                ("is_deleted", models.BooleanField(default=False, editable=False)),
                ("slug", models.SlugField(max_length=100, unique=True)),
                ("name", models.CharField(max_length=150)),
                ("description", models.TextField(blank=True)),
            ],
            options={
                "verbose_name": "Widget Zone",
                "verbose_name_plural": "Widget Zones",
                "ordering": ("slug",),
            },
        ),
        migrations.CreateModel(
            name="Widget",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("is_seed_data", models.BooleanField(default=False, editable=False)),
                ("is_user_data", models.BooleanField(default=False, editable=False)),
                ("is_deleted", models.BooleanField(default=False, editable=False)),
                ("slug", models.SlugField(max_length=100, unique=True)),
                ("name", models.CharField(max_length=150)),
                ("description", models.TextField(blank=True)),
                ("template_name", models.CharField(max_length=255)),
                ("renderer_path", models.CharField(max_length=255)),
                ("is_enabled", models.BooleanField(default=True)),
                ("priority", models.IntegerField(default=0)),
                (
                    "zone",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="widgets",
                        to="widgets.widgetzone",
                    ),
                ),
            ],
            options={
                "verbose_name": "Widget",
                "verbose_name_plural": "Widgets",
                "ordering": ("priority", "pk"),
            },
        ),
        migrations.CreateModel(
            name="WidgetProfile",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("is_seed_data", models.BooleanField(default=False, editable=False)),
                ("is_user_data", models.BooleanField(default=False, editable=False)),
                ("is_deleted", models.BooleanField(default=False, editable=False)),
                ("is_enabled", models.BooleanField(default=True)),
                (
                    "group",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        to="auth.group",
                    ),
                ),
                (
                    "user",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="widget_profiles",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "widget",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="profiles",
                        to="widgets.widget",
                    ),
                ),
            ],
            options={
                "verbose_name": "Widget Profile",
                "verbose_name_plural": "Widget Profiles",
                "constraints": [
                    models.CheckConstraint(
                        condition=models.Q(
                            ("user__isnull", False),
                            ("group__isnull", False),
                            _connector="OR",
                        ),
                        name="widgets_profile_requires_target",
                    ),
                    models.UniqueConstraint(
                        condition=models.Q(("user__isnull", False)),
                        fields=("widget", "user"),
                        name="widgets_unique_user_profile",
                    ),
                    models.UniqueConstraint(
                        condition=models.Q(("group__isnull", False)),
                        fields=("widget", "group"),
                        name="widgets_unique_group_profile",
                    ),
                ],
            },
        ),
    ]
