# Generated by Django 4.2.4 on 2023-08-14 17:15

from django.conf import settings
import django.core.serializers.json
from django.db import migrations, models
import django.db.models.deletion
import uuid


class Migration(migrations.Migration):
    initial = True

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

    operations = [
        migrations.CreateModel(
            name="Entry",
            fields=[
                ("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
                ("uuid", models.UUIDField(default=uuid.uuid4, verbose_name="UUID")),
                ("is_visible", models.BooleanField(default=True, verbose_name="visible")),
                ("created", models.DateTimeField(auto_now_add=True, verbose_name="created date")),
                ("description", models.TextField(blank=True, verbose_name="description")),
                ("content", models.TextField(verbose_name="content")),
                (
                    "user",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE, related_name="entries", to=settings.AUTH_USER_MODEL
                    ),
                ),
            ],
            options={
                "verbose_name": "entry",
                "verbose_name_plural": "entries",
            },
        ),
        migrations.CreateModel(
            name="EntryApproval",
            fields=[
                ("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
                (
                    "sandbox",
                    models.JSONField(
                        default=dict, encoder=django.core.serializers.json.DjangoJSONEncoder, verbose_name="Data"
                    ),
                ),
                (
                    "approved",
                    models.BooleanField(
                        choices=[(None, "Pending"), (False, "Rejected"), (True, "Approved")],
                        default=None,
                        null=True,
                        verbose_name="Moderated",
                    ),
                ),
                (
                    "draft",
                    models.BooleanField(
                        choices=[(False, "Draft"), (True, "Waiting for moderation")], default=True, verbose_name="Draft"
                    ),
                ),
                ("approval_date", models.DateTimeField(null=True, verbose_name="Moderated at")),
                ("info", models.TextField(blank=True, verbose_name="Reason")),
                ("updated", models.DateTimeField(auto_now=True, verbose_name="Updated")),
                (
                    "moderator",
                    models.ForeignKey(
                        blank=True,
                        default=None,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="moderated_entry_approval",
                        to=settings.AUTH_USER_MODEL,
                        verbose_name="Moderated by",
                    ),
                ),
                (
                    "source",
                    models.OneToOneField(
                        on_delete=django.db.models.deletion.CASCADE, related_name="approval", to="content.entry"
                    ),
                ),
            ],
            options={
                "verbose_name": "entry approval",
                "verbose_name_plural": "entry approvals",
                "db_table": "content_entry_approval",
                "permissions": [["moderate_content_entry_approval", "can moderate entry"]],
                "abstract": False,
            },
        ),
        migrations.AddIndex(
            model_name="entry",
            index=models.Index(fields=["created"], name="idx_created"),
        ),
    ]
