# Generated by Django 5.2.10 on 2026-01-11 18:06

import apps.core.choices.fields
import django.db.models.deletion
import uuid
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ("moderation", "0009_add_claim_fields"),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name="ModerationAuditLog",
            fields=[
                ("id", models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                (
                    "action",
                    apps.core.choices.fields.RichChoiceField(
                        allow_deprecated=False,
                        choice_group="moderation_audit_actions",
                        choices=[
                            ("approved", "Approved"),
                            ("rejected", "Rejected"),
                            ("claimed", "Claimed"),
                            ("unclaimed", "Unclaimed"),
                            ("escalated", "Escalated"),
                            ("converted_to_edit", "Converted to Edit"),
                            ("status_changed", "Status Changed"),
                            ("notes_added", "Notes Added"),
                            ("auto_approved", "Auto Approved"),
                        ],
                        db_index=True,
                        domain="moderation",
                        help_text="The action that was performed",
                        max_length=50,
                    ),
                ),
                (
                    "previous_status",
                    models.CharField(blank=True, help_text="Status before the action", max_length=50, null=True),
                ),
                (
                    "new_status",
                    models.CharField(blank=True, help_text="Status after the action", max_length=50, null=True),
                ),
                ("notes", models.TextField(blank=True, help_text="Notes or comments about the action", null=True)),
                (
                    "is_system_action",
                    models.BooleanField(
                        db_index=True, default=False, help_text="Whether this was an automated system action"
                    ),
                ),
                ("is_test_data", models.BooleanField(default=False, help_text="Whether this is test data")),
                (
                    "created_at",
                    models.DateTimeField(auto_now_add=True, db_index=True, help_text="When this action was performed"),
                ),
                (
                    "moderator",
                    models.ForeignKey(
                        blank=True,
                        help_text="The moderator who performed the action (null for system actions)",
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="moderation_audit_logs",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "submission",
                    models.ForeignKey(
                        help_text="The submission this audit log entry is for",
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="audit_logs",
                        to="moderation.editsubmission",
                    ),
                ),
            ],
            options={
                "verbose_name": "Moderation Audit Log",
                "verbose_name_plural": "Moderation Audit Logs",
                "ordering": ["-created_at"],
                "indexes": [
                    models.Index(fields=["submission", "created_at"], name="moderation__submiss_2f5e56_idx"),
                    models.Index(fields=["moderator", "created_at"], name="moderation__moderat_591c14_idx"),
                    models.Index(fields=["action", "created_at"], name="moderation__action_a98c47_idx"),
                ],
            },
        ),
    ]
