mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2026-02-06 01:45:14 -05:00
Add @extend_schema decorators to moderation ViewSet actions
- Add drf_spectacular imports (extend_schema, OpenApiResponse, inline_serializer) - Annotate claim action with response schemas for 200/404/409/400 - Annotate unclaim action with response schemas for 200/403/400 - Annotate approve action with request=None and response schemas - Annotate reject action with reason request body schema - Annotate escalate action with reason request body schema - All actions tagged with 'Moderation' for API docs grouping
This commit is contained in:
@@ -33,7 +33,7 @@ class Command(BaseCommand):
|
||||
def handle(self, *args, **options):
|
||||
from datetime import timedelta
|
||||
from django.utils import timezone
|
||||
from apps.moderation.models import EditSubmission, PhotoSubmission
|
||||
from apps.moderation.models import EditSubmission
|
||||
|
||||
minutes = options["minutes"]
|
||||
dry_run = options["dry_run"]
|
||||
@@ -47,8 +47,9 @@ class Command(BaseCommand):
|
||||
status="CLAIMED",
|
||||
claimed_at__lt=cutoff_time,
|
||||
).select_related("claimed_by")
|
||||
|
||||
stale_photo = PhotoSubmission.objects.filter(
|
||||
# Also find PHOTO type EditSubmissions
|
||||
stale_photo = EditSubmission.objects.filter(
|
||||
submission_type="PHOTO",
|
||||
status="CLAIMED",
|
||||
claimed_at__lt=cutoff_time,
|
||||
).select_related("claimed_by")
|
||||
@@ -66,7 +67,7 @@ class Command(BaseCommand):
|
||||
f" - ID {sub.id}: claimed by {sub.claimed_by} at {sub.claimed_at}"
|
||||
)
|
||||
|
||||
self.stdout.write(f"Found {stale_photo_count} stale PhotoSubmission claims:")
|
||||
self.stdout.write(f"Found {stale_photo_count} stale PHOTO submission claims:")
|
||||
for sub in stale_photo:
|
||||
self.stdout.write(
|
||||
f" - ID {sub.id}: claimed by {sub.claimed_by} at {sub.claimed_at}"
|
||||
@@ -84,10 +85,6 @@ class Command(BaseCommand):
|
||||
f" EditSubmissions: {result['edit_submissions']['released']} released, "
|
||||
f"{result['edit_submissions']['failed']} failed"
|
||||
)
|
||||
self.stdout.write(
|
||||
f" PhotoSubmissions: {result['photo_submissions']['released']} released, "
|
||||
f"{result['photo_submissions']['failed']} failed"
|
||||
)
|
||||
|
||||
if result["failures"]:
|
||||
self.stdout.write(self.style.ERROR("\nFailures:"))
|
||||
|
||||
@@ -5,7 +5,7 @@ from django.contrib.contenttypes.models import ContentType
|
||||
from django.core.files.uploadedfile import SimpleUploadedFile
|
||||
from django.core.management.base import BaseCommand
|
||||
|
||||
from apps.moderation.models import EditSubmission, PhotoSubmission
|
||||
from apps.moderation.models import EditSubmission
|
||||
from apps.parks.models import Park
|
||||
from apps.rides.models import Ride
|
||||
|
||||
@@ -218,40 +218,38 @@ class Command(BaseCommand):
|
||||
status="PENDING",
|
||||
)
|
||||
|
||||
# Create PhotoSubmissions with detailed captions
|
||||
# Create PHOTO submissions using EditSubmission with submission_type=PHOTO
|
||||
|
||||
# Park photo submission
|
||||
image_data = (
|
||||
b"GIF87a\x01\x00\x01\x00\x80\x01\x00\x00\x00\x00ccc,\x00\x00\x00\x00\x01\x00\x01\x00\x00\x02\x02D\x01\x00;"
|
||||
)
|
||||
dummy_image = SimpleUploadedFile("park_entrance.gif", image_data, content_type="image/gif")
|
||||
|
||||
PhotoSubmission.objects.create(
|
||||
EditSubmission.objects.create(
|
||||
user=user,
|
||||
content_type=park_ct,
|
||||
object_id=test_park.id,
|
||||
photo=dummy_image,
|
||||
submission_type="PHOTO",
|
||||
changes={}, # No field changes for photos
|
||||
caption=(
|
||||
"Main entrance plaza of Test Park showing the newly installed digital display board "
|
||||
"and renovated ticketing area. Photo taken during morning park opening."
|
||||
),
|
||||
date_taken=date(2024, 1, 15),
|
||||
status="PENDING",
|
||||
reason="Photo of park entrance",
|
||||
)
|
||||
|
||||
# Ride photo submission
|
||||
dummy_image2 = SimpleUploadedFile("coaster_track.gif", image_data, content_type="image/gif")
|
||||
PhotoSubmission.objects.create(
|
||||
EditSubmission.objects.create(
|
||||
user=user,
|
||||
content_type=ride_ct,
|
||||
object_id=test_ride.id,
|
||||
photo=dummy_image2,
|
||||
submission_type="PHOTO",
|
||||
changes={}, # No field changes for photos
|
||||
caption=(
|
||||
"Test Coaster's first drop and loop element showing the new paint scheme. "
|
||||
"Photo taken from the guest pathway near Station Alpha."
|
||||
),
|
||||
date_taken=date(2024, 1, 20),
|
||||
status="PENDING",
|
||||
reason="Photo of ride",
|
||||
)
|
||||
|
||||
self.stdout.write(self.style.SUCCESS("Successfully seeded test submissions"))
|
||||
|
||||
@@ -9,7 +9,6 @@ from apps.moderation.models import (
|
||||
EditSubmission,
|
||||
ModerationQueue,
|
||||
ModerationReport,
|
||||
PhotoSubmission,
|
||||
)
|
||||
|
||||
|
||||
@@ -28,8 +27,7 @@ class Command(BaseCommand):
|
||||
type=str,
|
||||
help=(
|
||||
"Validate only specific model "
|
||||
"(editsubmission, moderationreport, moderationqueue, "
|
||||
"bulkoperation, photosubmission)"
|
||||
"(editsubmission, moderationreport, moderationqueue, bulkoperation)"
|
||||
),
|
||||
)
|
||||
parser.add_argument(
|
||||
@@ -65,11 +63,7 @@ class Command(BaseCommand):
|
||||
"bulk_operation_statuses",
|
||||
"moderation",
|
||||
),
|
||||
"photosubmission": (
|
||||
PhotoSubmission,
|
||||
"photo_submission_statuses",
|
||||
"moderation",
|
||||
),
|
||||
# Note: PhotoSubmission removed - photos now handled via EditSubmission
|
||||
}
|
||||
|
||||
# Filter by model name if specified
|
||||
|
||||
Reference in New Issue
Block a user