# Generated by Django 5.2.4 on 2025-10-05 21:25

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


class Migration(migrations.Migration):

    dependencies = [
        ("core", "0065_remove_socialprofile_socialprofile_network_handle_and_more"),
        ("nodes", "0016_contentclassifier_contenttag_contentclassification"),
        ("pages", "0017_landinglead"),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.AlterModelOptions(
            name="rolelanding",
            options={
                "ordering": ("-priority", "pk"),
                "verbose_name": "Default Landing",
                "verbose_name_plural": "Default Landings",
            },
        ),
        migrations.AddField(
            model_name="rolelanding",
            name="priority",
            field=models.IntegerField(default=0),
        ),
        migrations.AddField(
            model_name="rolelanding",
            name="security_group",
            field=models.OneToOneField(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                related_name="default_landing",
                to="core.securitygroup",
            ),
        ),
        migrations.AddField(
            model_name="rolelanding",
            name="user",
            field=models.OneToOneField(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                related_name="default_landing",
                to=settings.AUTH_USER_MODEL,
            ),
        ),
        migrations.AlterField(
            model_name="rolelanding",
            name="node_role",
            field=models.OneToOneField(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                related_name="default_landing",
                to="nodes.noderole",
            ),
        ),
        migrations.AddConstraint(
            model_name="rolelanding",
            constraint=models.CheckConstraint(
                condition=models.Q(
                    models.Q(
                        ("node_role__isnull", False),
                        ("security_group__isnull", True),
                        ("user__isnull", True),
                    ),
                    models.Q(
                        ("node_role__isnull", True),
                        ("security_group__isnull", False),
                        ("user__isnull", True),
                    ),
                    models.Q(
                        ("node_role__isnull", True),
                        ("security_group__isnull", True),
                        ("user__isnull", False),
                    ),
                    _connector="OR",
                ),
                name="pages_rolelanding_single_target",
            ),
        ),
    ]
