mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-22 10:11:13 -05:00
Refactor code structure and remove redundant changes
This commit is contained in:
236
django-backend/apps/reports/migrations/0001_initial.py
Normal file
236
django-backend/apps/reports/migrations/0001_initial.py
Normal file
@@ -0,0 +1,236 @@
|
||||
# Generated by Django 4.2.8 on 2025-11-09 15:50
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
import pgtrigger.compiler
|
||||
import pgtrigger.migrations
|
||||
import uuid
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
("pghistory", "0006_delete_aggregateevent"),
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name="Report",
|
||||
fields=[
|
||||
(
|
||||
"id",
|
||||
models.UUIDField(
|
||||
default=uuid.uuid4,
|
||||
editable=False,
|
||||
primary_key=True,
|
||||
serialize=False,
|
||||
),
|
||||
),
|
||||
("entity_type", models.CharField(db_index=True, max_length=50)),
|
||||
("entity_id", models.UUIDField(db_index=True)),
|
||||
(
|
||||
"report_type",
|
||||
models.CharField(
|
||||
choices=[
|
||||
("inappropriate", "Inappropriate Content"),
|
||||
("inaccurate", "Inaccurate Information"),
|
||||
("spam", "Spam"),
|
||||
("duplicate", "Duplicate"),
|
||||
("copyright", "Copyright Violation"),
|
||||
("other", "Other"),
|
||||
],
|
||||
max_length=50,
|
||||
),
|
||||
),
|
||||
("description", models.TextField()),
|
||||
(
|
||||
"status",
|
||||
models.CharField(
|
||||
choices=[
|
||||
("pending", "Pending Review"),
|
||||
("reviewing", "Under Review"),
|
||||
("resolved", "Resolved"),
|
||||
("dismissed", "Dismissed"),
|
||||
],
|
||||
db_index=True,
|
||||
default="pending",
|
||||
max_length=20,
|
||||
),
|
||||
),
|
||||
("reviewed_at", models.DateTimeField(blank=True, null=True)),
|
||||
("resolution_notes", models.TextField(blank=True, null=True)),
|
||||
("created_at", models.DateTimeField(auto_now_add=True)),
|
||||
("updated_at", models.DateTimeField(auto_now=True)),
|
||||
(
|
||||
"reported_by",
|
||||
models.ForeignKey(
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
related_name="reports_created",
|
||||
to=settings.AUTH_USER_MODEL,
|
||||
),
|
||||
),
|
||||
(
|
||||
"reviewed_by",
|
||||
models.ForeignKey(
|
||||
blank=True,
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.SET_NULL,
|
||||
related_name="reports_reviewed",
|
||||
to=settings.AUTH_USER_MODEL,
|
||||
),
|
||||
),
|
||||
],
|
||||
options={
|
||||
"verbose_name": "Report",
|
||||
"verbose_name_plural": "Reports",
|
||||
"ordering": ["-created_at"],
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name="ReportEvent",
|
||||
fields=[
|
||||
("pgh_id", models.AutoField(primary_key=True, serialize=False)),
|
||||
("pgh_created_at", models.DateTimeField(auto_now_add=True)),
|
||||
("pgh_label", models.TextField(help_text="The event label.")),
|
||||
(
|
||||
"id",
|
||||
models.UUIDField(
|
||||
default=uuid.uuid4, editable=False, serialize=False
|
||||
),
|
||||
),
|
||||
("entity_type", models.CharField(max_length=50)),
|
||||
("entity_id", models.UUIDField()),
|
||||
(
|
||||
"report_type",
|
||||
models.CharField(
|
||||
choices=[
|
||||
("inappropriate", "Inappropriate Content"),
|
||||
("inaccurate", "Inaccurate Information"),
|
||||
("spam", "Spam"),
|
||||
("duplicate", "Duplicate"),
|
||||
("copyright", "Copyright Violation"),
|
||||
("other", "Other"),
|
||||
],
|
||||
max_length=50,
|
||||
),
|
||||
),
|
||||
("description", models.TextField()),
|
||||
(
|
||||
"status",
|
||||
models.CharField(
|
||||
choices=[
|
||||
("pending", "Pending Review"),
|
||||
("reviewing", "Under Review"),
|
||||
("resolved", "Resolved"),
|
||||
("dismissed", "Dismissed"),
|
||||
],
|
||||
default="pending",
|
||||
max_length=20,
|
||||
),
|
||||
),
|
||||
("reviewed_at", models.DateTimeField(blank=True, null=True)),
|
||||
("resolution_notes", models.TextField(blank=True, null=True)),
|
||||
("created_at", models.DateTimeField(auto_now_add=True)),
|
||||
("updated_at", models.DateTimeField(auto_now=True)),
|
||||
(
|
||||
"pgh_context",
|
||||
models.ForeignKey(
|
||||
db_constraint=False,
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.DO_NOTHING,
|
||||
related_name="+",
|
||||
related_query_name="+",
|
||||
to="pghistory.context",
|
||||
),
|
||||
),
|
||||
(
|
||||
"pgh_obj",
|
||||
models.ForeignKey(
|
||||
db_constraint=False,
|
||||
on_delete=django.db.models.deletion.DO_NOTHING,
|
||||
related_name="events",
|
||||
related_query_name="+",
|
||||
to="reports.report",
|
||||
),
|
||||
),
|
||||
(
|
||||
"reported_by",
|
||||
models.ForeignKey(
|
||||
db_constraint=False,
|
||||
on_delete=django.db.models.deletion.DO_NOTHING,
|
||||
related_name="+",
|
||||
related_query_name="+",
|
||||
to=settings.AUTH_USER_MODEL,
|
||||
),
|
||||
),
|
||||
(
|
||||
"reviewed_by",
|
||||
models.ForeignKey(
|
||||
blank=True,
|
||||
db_constraint=False,
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.DO_NOTHING,
|
||||
related_name="+",
|
||||
related_query_name="+",
|
||||
to=settings.AUTH_USER_MODEL,
|
||||
),
|
||||
),
|
||||
],
|
||||
options={
|
||||
"abstract": False,
|
||||
},
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name="report",
|
||||
index=models.Index(
|
||||
fields=["entity_type", "entity_id"],
|
||||
name="reports_rep_entity__eef0d7_idx",
|
||||
),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name="report",
|
||||
index=models.Index(
|
||||
fields=["status", "-created_at"], name="reports_rep_status_7dd5e5_idx"
|
||||
),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name="report",
|
||||
index=models.Index(
|
||||
fields=["reported_by", "-created_at"],
|
||||
name="reports_rep_reporte_975d91_idx",
|
||||
),
|
||||
),
|
||||
pgtrigger.migrations.AddTrigger(
|
||||
model_name="report",
|
||||
trigger=pgtrigger.compiler.Trigger(
|
||||
name="insert_insert",
|
||||
sql=pgtrigger.compiler.UpsertTriggerSql(
|
||||
func='INSERT INTO "reports_reportevent" ("created_at", "description", "entity_id", "entity_type", "id", "pgh_context_id", "pgh_created_at", "pgh_label", "pgh_obj_id", "report_type", "reported_by_id", "resolution_notes", "reviewed_at", "reviewed_by_id", "status", "updated_at") VALUES (NEW."created_at", NEW."description", NEW."entity_id", NEW."entity_type", NEW."id", _pgh_attach_context(), NOW(), \'insert\', NEW."id", NEW."report_type", NEW."reported_by_id", NEW."resolution_notes", NEW."reviewed_at", NEW."reviewed_by_id", NEW."status", NEW."updated_at"); RETURN NULL;',
|
||||
hash="7e22782db4f84b95a18bb1032e82b80fc3b3e5f5",
|
||||
operation="INSERT",
|
||||
pgid="pgtrigger_insert_insert_84ceb",
|
||||
table="reports_report",
|
||||
when="AFTER",
|
||||
),
|
||||
),
|
||||
),
|
||||
pgtrigger.migrations.AddTrigger(
|
||||
model_name="report",
|
||||
trigger=pgtrigger.compiler.Trigger(
|
||||
name="update_update",
|
||||
sql=pgtrigger.compiler.UpsertTriggerSql(
|
||||
condition="WHEN (OLD.* IS DISTINCT FROM NEW.*)",
|
||||
func='INSERT INTO "reports_reportevent" ("created_at", "description", "entity_id", "entity_type", "id", "pgh_context_id", "pgh_created_at", "pgh_label", "pgh_obj_id", "report_type", "reported_by_id", "resolution_notes", "reviewed_at", "reviewed_by_id", "status", "updated_at") VALUES (NEW."created_at", NEW."description", NEW."entity_id", NEW."entity_type", NEW."id", _pgh_attach_context(), NOW(), \'update\', NEW."id", NEW."report_type", NEW."reported_by_id", NEW."resolution_notes", NEW."reviewed_at", NEW."reviewed_by_id", NEW."status", NEW."updated_at"); RETURN NULL;',
|
||||
hash="ca714a1c7581855e9fc840a8267b63f2b5762b75",
|
||||
operation="UPDATE",
|
||||
pgid="pgtrigger_update_update_234a9",
|
||||
table="reports_report",
|
||||
when="AFTER",
|
||||
),
|
||||
),
|
||||
),
|
||||
]
|
||||
Reference in New Issue
Block a user