# Generated by Django 5.2.7 on 2025-10-29 01:32

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


class Migration(migrations.Migration):
    dependencies = [
        ("submissions", "0003_steamapikey"),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name="Submission",
            fields=[
                (
                    "id",
                    models.UUIDField(
                        default=uuid.uuid4,
                        editable=False,
                        primary_key=True,
                        serialize=False,
                    ),
                ),
                (
                    "notes",
                    models.TextField(
                        blank=True, help_text="Optional notes about the submission"
                    ),
                ),
                (
                    "is_validated",
                    models.BooleanField(
                        default=False,
                        help_text="Whether this submission has been manually validated",
                    ),
                ),
                (
                    "validated_at",
                    models.DateTimeField(
                        blank=True,
                        help_text="When this submission was validated",
                        null=True,
                    ),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "user",
                    models.ForeignKey(
                        blank=True,
                        help_text="User who made the submission (null for anonymous)",
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "validated_by",
                    models.ForeignKey(
                        blank=True,
                        help_text="Admin user who validated this submission",
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="validated_submissions",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "verbose_name": "Submission",
                "verbose_name_plural": "Submissions",
                "ordering": ["-created_at"],
            },
        ),
        migrations.CreateModel(
            name="PuzzleResponse",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "puzzle_name",
                    models.CharField(
                        help_text="Puzzle name as detected by OCR", max_length=255
                    ),
                ),
                (
                    "cost",
                    models.CharField(
                        blank=True, help_text="Cost value from OCR", max_length=20
                    ),
                ),
                (
                    "cycles",
                    models.CharField(
                        blank=True, help_text="Cycles value from OCR", max_length=20
                    ),
                ),
                (
                    "area",
                    models.CharField(
                        blank=True, help_text="Area value from OCR", max_length=20
                    ),
                ),
                (
                    "needs_manual_validation",
                    models.BooleanField(
                        default=False,
                        help_text="Whether OCR failed and manual validation is needed",
                    ),
                ),
                (
                    "ocr_confidence_score",
                    models.FloatField(
                        blank=True,
                        help_text="OCR confidence score (0.0 to 1.0)",
                        null=True,
                    ),
                ),
                (
                    "validated_cost",
                    models.CharField(
                        blank=True,
                        help_text="Manually validated cost value",
                        max_length=20,
                    ),
                ),
                (
                    "validated_cycles",
                    models.CharField(
                        blank=True,
                        help_text="Manually validated cycles value",
                        max_length=20,
                    ),
                ),
                (
                    "validated_area",
                    models.CharField(
                        blank=True,
                        help_text="Manually validated area value",
                        max_length=20,
                    ),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "puzzle",
                    models.ForeignKey(
                        help_text="The puzzle this response is for",
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="responses",
                        to="submissions.steamcollectionitem",
                    ),
                ),
                (
                    "submission",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="responses",
                        to="submissions.submission",
                    ),
                ),
            ],
            options={
                "verbose_name": "Puzzle Response",
                "verbose_name_plural": "Puzzle Responses",
                "ordering": ["submission", "puzzle__order_index"],
                "unique_together": {("submission", "puzzle")},
            },
        ),
        migrations.CreateModel(
            name="SubmissionFile",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "file",
                    models.FileField(
                        help_text="Uploaded file (image/gif)",
                        upload_to=submissions.models.submission_file_upload_path,
                    ),
                ),
                (
                    "original_filename",
                    models.CharField(
                        help_text="Original filename as uploaded by user",
                        max_length=255,
                    ),
                ),
                (
                    "file_size",
                    models.PositiveIntegerField(help_text="File size in bytes"),
                ),
                (
                    "content_type",
                    models.CharField(help_text="MIME type of the file", max_length=100),
                ),
                (
                    "ocr_processed",
                    models.BooleanField(
                        default=False,
                        help_text="Whether OCR has been processed for this file",
                    ),
                ),
                (
                    "ocr_raw_data",
                    models.JSONField(
                        blank=True, help_text="Raw OCR data as JSON", null=True
                    ),
                ),
                (
                    "ocr_error",
                    models.TextField(
                        blank=True, help_text="OCR processing error message"
                    ),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "response",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="files",
                        to="submissions.puzzleresponse",
                    ),
                ),
            ],
            options={
                "verbose_name": "Submission File",
                "verbose_name_plural": "Submission Files",
                "ordering": ["response", "created_at"],
            },
        ),
    ]
