# Generated by Django 4.1.5 on 2023-04-26 08:00

import uuid

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


class Migration(migrations.Migration):
    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name="FormComponents",
            fields=[
                (
                    "order",
                    models.PositiveIntegerField(
                        db_index=True, editable=False, verbose_name="order"
                    ),
                ),
                (
                    "id",
                    models.UUIDField(
                        default=uuid.uuid4, primary_key=True, serialize=False
                    ),
                ),
                ("created", models.DateTimeField(auto_now_add=True, null=True)),
                ("updated", models.DateTimeField(auto_now=True, null=True)),
                (
                    "label",
                    models.CharField(
                        default=uuid.uuid4,
                        help_text="Used as a human-readable label",
                        max_length=1024,
                        unique=True,
                    ),
                ),
                (
                    "created_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "ordering": ("schema", "order"),
            },
        ),
        migrations.CreateModel(
            name="FormKitSchemaNode",
            fields=[
                (
                    "id",
                    models.UUIDField(
                        default=uuid.uuid4, primary_key=True, serialize=False
                    ),
                ),
                ("created", models.DateTimeField(auto_now_add=True, null=True)),
                ("updated", models.DateTimeField(auto_now=True, null=True)),
                (
                    "node_type",
                    models.CharField(
                        blank=True,
                        choices=[
                            ("$cmp", "Component"),
                            ("text", "Text"),
                            ("condition", "Condition"),
                            ("$formkit", "FormKit"),
                            ("$el", "Element"),
                            ("raw", "Raw JSON"),
                        ],
                        max_length=256,
                    ),
                ),
                (
                    "description",
                    models.CharField(
                        blank=True,
                        help_text="Decribe the type of data / reason for this component",
                        max_length=4000,
                        null=True,
                    ),
                ),
                (
                    "label",
                    models.CharField(
                        help_text="Used as a human-readable label",
                        max_length=1024,
                        unique=True,
                    ),
                ),
                (
                    "node",
                    models.JSONField(
                        blank=True,
                        help_text="A JSON representation of select parts of the FormKit schema",
                        null=True,
                    ),
                ),
                (
                    "additional_props",
                    models.JSONField(
                        blank=True,
                        help_text="User space for additional, less used props",
                        null=True,
                    ),
                ),
                (
                    "translation_context",
                    models.CharField(
                        blank=True,
                        help_text="The gettext context to use to translate Options, label, placeholder and help text",
                        max_length=1024,
                        null=True,
                    ),
                ),
            ],
            options={
                "abstract": False,
            },
        ),
        migrations.CreateModel(
            name="Translatable",
            fields=[
                (
                    "id",
                    models.UUIDField(
                        default=uuid.uuid4, primary_key=True, serialize=False
                    ),
                ),
                ("created", models.DateTimeField(auto_now_add=True, null=True)),
                ("updated", models.DateTimeField(auto_now=True, null=True)),
                (
                    "object_id",
                    models.UUIDField(
                        editable=False,
                        help_text="The UUID of the model which this translation relates to",
                    ),
                ),
                ("language_code", models.CharField(editable=False, max_length=3)),
                (
                    "field",
                    models.CharField(
                        editable=False,
                        help_text="The field on the generic model to translate",
                        max_length=100,
                    ),
                ),
                (
                    "value",
                    models.CharField(
                        blank=True, editable=False, max_length=5000, null=True
                    ),
                ),
                (
                    "context",
                    models.CharField(
                        blank=True, editable=False, max_length=1024, null=True
                    ),
                ),
                ("msgstr", models.CharField(help_text="The string", max_length=5000)),
                (
                    "created_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "updated_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "abstract": False,
            },
        ),
        migrations.CreateModel(
            name="Option",
            fields=[
                (
                    "order",
                    models.PositiveIntegerField(
                        db_index=True, editable=False, verbose_name="order"
                    ),
                ),
                (
                    "id",
                    models.UUIDField(
                        default=uuid.uuid4, primary_key=True, serialize=False
                    ),
                ),
                ("created", models.DateTimeField(auto_now_add=True, null=True)),
                ("updated", models.DateTimeField(auto_now=True, null=True)),
                ("value", models.CharField(max_length=1024)),
                ("label", models.CharField(max_length=1024)),
                (
                    "created_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "field",
                    models.ForeignKey(
                        limit_choices_to={"node__formkit__in": ["select", "radio"]},
                        on_delete=django.db.models.deletion.CASCADE,
                        to="formkit_ninja.formkitschemanode",
                    ),
                ),
                (
                    "updated_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "ordering": ("order",),
                "abstract": False,
            },
        ),
        migrations.CreateModel(
            name="NodeChildren",
            fields=[
                (
                    "order",
                    models.PositiveIntegerField(
                        db_index=True, editable=False, verbose_name="order"
                    ),
                ),
                (
                    "id",
                    models.UUIDField(
                        default=uuid.uuid4, primary_key=True, serialize=False
                    ),
                ),
                ("created", models.DateTimeField(auto_now_add=True, null=True)),
                ("updated", models.DateTimeField(auto_now=True, null=True)),
                (
                    "child",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="parent",
                        to="formkit_ninja.formkitschemanode",
                    ),
                ),
                (
                    "created_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "parent",
                    models.ForeignKey(
                        limit_choices_to={"node__node_type": "$el"},
                        on_delete=django.db.models.deletion.CASCADE,
                        to="formkit_ninja.formkitschemanode",
                    ),
                ),
                (
                    "updated_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "ordering": ("order",),
            },
        ),
        migrations.CreateModel(
            name="Membership",
            fields=[
                (
                    "order",
                    models.PositiveIntegerField(
                        db_index=True, editable=False, verbose_name="order"
                    ),
                ),
                (
                    "id",
                    models.UUIDField(
                        default=uuid.uuid4, primary_key=True, serialize=False
                    ),
                ),
                ("created", models.DateTimeField(auto_now_add=True, null=True)),
                ("updated", models.DateTimeField(auto_now=True, null=True)),
                (
                    "created_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "group",
                    models.ForeignKey(
                        limit_choices_to={"node__formkit": "group"},
                        on_delete=django.db.models.deletion.CASCADE,
                        to="formkit_ninja.formkitschemanode",
                    ),
                ),
                (
                    "member",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="members",
                        to="formkit_ninja.formkitschemanode",
                    ),
                ),
                (
                    "updated_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "ordering": ("order",),
                "abstract": False,
            },
        ),
        migrations.AddField(
            model_name="formkitschemanode",
            name="children",
            field=models.ManyToManyField(
                blank=True,
                through="formkit_ninja.NodeChildren",
                to="formkit_ninja.formkitschemanode",
            ),
        ),
        migrations.AddField(
            model_name="formkitschemanode",
            name="created_by",
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.PROTECT,
                related_name="+",
                to=settings.AUTH_USER_MODEL,
            ),
        ),
        migrations.AddField(
            model_name="formkitschemanode",
            name="group",
            field=models.ManyToManyField(
                blank=True,
                through="formkit_ninja.Membership",
                to="formkit_ninja.formkitschemanode",
            ),
        ),
        migrations.AddField(
            model_name="formkitschemanode",
            name="updated_by",
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.PROTECT,
                related_name="+",
                to=settings.AUTH_USER_MODEL,
            ),
        ),
        migrations.CreateModel(
            name="FormKitSchema",
            fields=[
                (
                    "id",
                    models.UUIDField(
                        default=uuid.uuid4, primary_key=True, serialize=False
                    ),
                ),
                ("created", models.DateTimeField(auto_now_add=True, null=True)),
                ("updated", models.DateTimeField(auto_now=True, null=True)),
                ("key", models.SlugField(max_length=1024, unique=True)),
                (
                    "created_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "nodes",
                    models.ManyToManyField(
                        through="formkit_ninja.FormComponents",
                        to="formkit_ninja.formkitschemanode",
                    ),
                ),
                (
                    "updated_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "abstract": False,
            },
        ),
        migrations.AddField(
            model_name="formcomponents",
            name="node",
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                to="formkit_ninja.formkitschemanode",
            ),
        ),
        migrations.AddField(
            model_name="formcomponents",
            name="schema",
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                to="formkit_ninja.formkitschema",
            ),
        ),
        migrations.AddField(
            model_name="formcomponents",
            name="updated_by",
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.PROTECT,
                related_name="+",
                to=settings.AUTH_USER_MODEL,
            ),
        ),
    ]
