# Generated by Django 5.2.12 on 2026-04-27 07:39

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


class Migration(migrations.Migration):
    dependencies = [("club", "0016_clubrole_alter_membership_role")]

    operations = [
        migrations.CreateModel(
            name="LinkType",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("name", models.CharField(max_length=40, verbose_name="name")),
                (
                    "url_base",
                    models.URLField(
                        help_text=(
                            "The base url that links with this type must respect"
                        ),
                        unique=True,
                        verbose_name="url base",
                    ),
                ),
                (
                    "icon",
                    models.CharField(
                        help_text=(
                            "The fontawesome class to use "
                            "(e.g. `fa-brands fa-instagram`)"
                        ),
                        max_length=40,
                        verbose_name="icon",
                    ),
                ),
            ],
            options={"verbose_name": "link type", "verbose_name_plural": "link types"},
        ),
        migrations.CreateModel(
            name="ClubLink",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "name",
                    models.CharField(blank=True, max_length=40, verbose_name="name"),
                ),
                ("url", models.URLField(verbose_name="link url")),
                (
                    "created_at",
                    models.DateTimeField(auto_now_add=True, verbose_name="created at"),
                ),
                (
                    "updated_at",
                    models.DateTimeField(auto_now=True, verbose_name="updated at"),
                ),
                (
                    "club",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="links",
                        to="club.club",
                        verbose_name="club",
                    ),
                ),
                (
                    "link_type",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="links",
                        to="club.linktype",
                        verbose_name="link type",
                    ),
                ),
            ],
            options={
                "verbose_name": "club link",
                "verbose_name_plural": "club links",
                "constraints": [
                    models.UniqueConstraint(
                        fields=["club", "url"],
                        name="club_clublink_unique_club_url",
                        violation_error_message="Duplicated url",
                    )
                ],
            },
        ),
    ]
