# Generated by Django 5.2.7 on 2025-10-22 09:38

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


class Migration(migrations.Migration):

    dependencies = [
        ("core", "0008_organization_osb_guid_service_osb_service_id_and_more"),
    ]

    operations = [
        migrations.AddField(
            model_name="controlplane",
            name="wildcard_dns",
            field=models.CharField(
                blank=True,
                help_text="Wildcard DNS domain for auto-generating FQDNs (e.g., apps.exoscale-ch-gva-2-prod2.services.servala.com)",
                max_length=255,
                null=True,
                verbose_name="Wildcard DNS",
            ),
        ),
        migrations.AddField(
            model_name="organization",
            name="limit_osb_services",
            field=models.ManyToManyField(
                blank=True,
                related_name="+",
                to="core.service",
                verbose_name="Services activated from OSB",
            ),
        ),
        migrations.AddField(
            model_name="organizationorigin",
            name="billing_entity",
            field=models.ForeignKey(
                help_text="If set, this billing entity will be used on new organizations with this origin.",
                null=True,
                on_delete=django.db.models.deletion.PROTECT,
                related_name="origins",
                to="core.billingentity",
                verbose_name="Billing entity",
            ),
        ),
        migrations.AddField(
            model_name="organizationorigin",
            name="default_odoo_sale_order_id",
            field=models.IntegerField(
                blank=True,
                help_text="If set, this sale order will be used for new organizations with this origin.",
                null=True,
                verbose_name="Default Odoo Sale Order ID",
            ),
        ),
        migrations.AddField(
            model_name="organizationorigin",
            name="limit_cloudproviders",
            field=models.ManyToManyField(
                blank=True,
                help_text="If set, all organizations with this origin will be limited to these cloud providers.",
                related_name="+",
                to="core.cloudprovider",
                verbose_name="Limit to these Cloud providers",
            ),
        ),
        migrations.AddField(
            model_name="servicedefinition",
            name="advanced_fields",
            field=models.JSONField(
                blank=True,
                default=list,
                help_text=(
                    "Array of field names that should be hidden behind an 'Advanced' toggle."
                    "Use dot notation (e.g., ['spec.parameters.monitoring.enabled', 'spec.parameters.backup.schedule'])"
                ),
                null=True,
                verbose_name="Advanced fields",
            ),
        ),
        migrations.AddField(
            model_name="serviceoffering",
            name="external_links",
            field=models.JSONField(
                blank=True,
                help_text='JSON array of link objects: {"url": "…", "title": "…"}. ',
                null=True,
                verbose_name="External links",
            ),
        ),
        migrations.CreateModel(
            name="OrganizationInvitation",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "created_at",
                    models.DateTimeField(auto_now_add=True, verbose_name="Created"),
                ),
                (
                    "updated_at",
                    models.DateTimeField(auto_now=True, verbose_name="Last updated"),
                ),
                (
                    "email",
                    models.EmailField(max_length=254, verbose_name="Email address"),
                ),
                (
                    "role",
                    models.CharField(
                        choices=[
                            ("member", "Member"),
                            ("admin", "Administrator"),
                            ("owner", "Owner"),
                        ],
                        default="member",
                        max_length=20,
                        verbose_name="Role",
                    ),
                ),
                (
                    "secret",
                    models.CharField(
                        editable=False,
                        max_length=64,
                        unique=True,
                        verbose_name="Secret token",
                    ),
                ),
                (
                    "accepted_at",
                    models.DateTimeField(
                        blank=True, null=True, verbose_name="Accepted at"
                    ),
                ),
                (
                    "accepted_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="accepted_invitations",
                        to=settings.AUTH_USER_MODEL,
                        verbose_name="Accepted by",
                    ),
                ),
                (
                    "created_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="created_invitations",
                        to=settings.AUTH_USER_MODEL,
                        verbose_name="Created by",
                    ),
                ),
                (
                    "organization",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="invitations",
                        to="core.organization",
                        verbose_name="Organization",
                    ),
                ),
            ],
            options={
                "verbose_name": "Organization invitation",
                "verbose_name_plural": "Organization invitations",
                "unique_together": {("organization", "email")},
            },
            bases=(rules.contrib.models.RulesModelMixin, models.Model),
        ),
    ]
