# Generated by Django 5.2.11 on 2026-02-21 11:48

import django.db.models.deletion
import mptt.fields
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="OrganizationalUnit",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("name", models.CharField(max_length=100)),
                (
                    "type",
                    models.CharField(
                        choices=[
                            ("ROOT", "Root"),
                            ("FACULTY", "faculty"),
                            ("DEPARTMENT", "department"),
                            ("GROUP", "Group"),
                        ],
                        max_length=20,
                    ),
                ),
                ("lft", models.PositiveIntegerField(editable=False)),
                ("rght", models.PositiveIntegerField(editable=False)),
                ("tree_id", models.PositiveIntegerField(db_index=True, editable=False)),
                ("level", models.PositiveIntegerField(editable=False)),
                (
                    "parent",
                    mptt.fields.TreeForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="children",
                        to="hierarchical_permissions.organizationalunit",
                    ),
                ),
            ],
            options={
                "abstract": False,
            },
        ),
        migrations.CreateModel(
            name="UserGroup",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "organizational_units",
                    models.ManyToManyField(
                        related_name="user_groups",
                        to="hierarchical_permissions.organizationalunit",
                    ),
                ),
                (
                    "permission_groups",
                    models.ManyToManyField(related_name="user_groups", to="auth.group"),
                ),
                (
                    "users",
                    models.ManyToManyField(
                        related_name="user_groups", to=settings.AUTH_USER_MODEL
                    ),
                ),
            ],
        ),
    ]
