mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2025-12-20 09:11:08 -05:00
Add migrations for ParkPhoto and RidePhoto models with associated events
- Created ParkPhoto and ParkPhotoEvent models in the parks app, including fields for image, caption, alt text, and relationships to the Park model. - Implemented triggers for insert and update operations on ParkPhoto to log changes in ParkPhotoEvent. - Created RidePhoto and RidePhotoEvent models in the rides app, with similar structure and functionality as ParkPhoto. - Added fields for photo type in RidePhoto and implemented corresponding triggers for logging changes. - Established necessary indexes and unique constraints for both models to ensure data integrity and optimize queries.
This commit is contained in:
@@ -3,18 +3,9 @@ Centralized map API views.
|
||||
Migrated from apps.core.views.map_views
|
||||
"""
|
||||
|
||||
import json
|
||||
import logging
|
||||
import time
|
||||
from typing import Dict, Any, Optional
|
||||
|
||||
from django.http import JsonResponse, HttpRequest
|
||||
from django.views.decorators.cache import cache_page
|
||||
from django.views.decorators.gzip import gzip_page
|
||||
from django.utils.decorators import method_decorator
|
||||
from django.views import View
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.conf import settings
|
||||
from django.http import HttpRequest
|
||||
from rest_framework.views import APIView
|
||||
from rest_framework.response import Response
|
||||
from rest_framework import status
|
||||
@@ -30,15 +21,54 @@ logger = logging.getLogger(__name__)
|
||||
summary="Get map locations",
|
||||
description="Get map locations with optional clustering and filtering.",
|
||||
parameters=[
|
||||
{"name": "north", "in": "query", "required": False, "schema": {"type": "number"}},
|
||||
{"name": "south", "in": "query", "required": False, "schema": {"type": "number"}},
|
||||
{"name": "east", "in": "query", "required": False, "schema": {"type": "number"}},
|
||||
{"name": "west", "in": "query", "required": False, "schema": {"type": "number"}},
|
||||
{"name": "zoom", "in": "query", "required": False, "schema": {"type": "integer"}},
|
||||
{"name": "types", "in": "query", "required": False, "schema": {"type": "string"}},
|
||||
{"name": "cluster", "in": "query", "required": False,
|
||||
"schema": {"type": "boolean"}},
|
||||
{"name": "q", "in": "query", "required": False, "schema": {"type": "string"}},
|
||||
{
|
||||
"name": "north",
|
||||
"in": "query",
|
||||
"required": False,
|
||||
"schema": {"type": "number"},
|
||||
},
|
||||
{
|
||||
"name": "south",
|
||||
"in": "query",
|
||||
"required": False,
|
||||
"schema": {"type": "number"},
|
||||
},
|
||||
{
|
||||
"name": "east",
|
||||
"in": "query",
|
||||
"required": False,
|
||||
"schema": {"type": "number"},
|
||||
},
|
||||
{
|
||||
"name": "west",
|
||||
"in": "query",
|
||||
"required": False,
|
||||
"schema": {"type": "number"},
|
||||
},
|
||||
{
|
||||
"name": "zoom",
|
||||
"in": "query",
|
||||
"required": False,
|
||||
"schema": {"type": "integer"},
|
||||
},
|
||||
{
|
||||
"name": "types",
|
||||
"in": "query",
|
||||
"required": False,
|
||||
"schema": {"type": "string"},
|
||||
},
|
||||
{
|
||||
"name": "cluster",
|
||||
"in": "query",
|
||||
"required": False,
|
||||
"schema": {"type": "boolean"},
|
||||
},
|
||||
{
|
||||
"name": "q",
|
||||
"in": "query",
|
||||
"required": False,
|
||||
"schema": {"type": "string"},
|
||||
},
|
||||
],
|
||||
responses={200: OpenApiTypes.OBJECT},
|
||||
tags=["Maps"],
|
||||
@@ -54,18 +84,20 @@ class MapLocationsAPIView(APIView):
|
||||
try:
|
||||
# Simple implementation to fix import error
|
||||
# TODO: Implement full functionality
|
||||
return Response({
|
||||
"status": "success",
|
||||
"message": "Map locations endpoint - implementation needed",
|
||||
"data": []
|
||||
})
|
||||
return Response(
|
||||
{
|
||||
"status": "success",
|
||||
"message": "Map locations endpoint - implementation needed",
|
||||
"data": [],
|
||||
}
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Error in MapLocationsAPIView: {str(e)}", exc_info=True)
|
||||
return Response({
|
||||
"status": "error",
|
||||
"message": "Failed to retrieve map locations"
|
||||
}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
|
||||
return Response(
|
||||
{"status": "error", "message": "Failed to retrieve map locations"},
|
||||
status=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
||||
)
|
||||
|
||||
|
||||
@extend_schema_view(
|
||||
@@ -73,10 +105,18 @@ class MapLocationsAPIView(APIView):
|
||||
summary="Get location details",
|
||||
description="Get detailed information about a specific location.",
|
||||
parameters=[
|
||||
{"name": "location_type", "in": "path",
|
||||
"required": True, "schema": {"type": "string"}},
|
||||
{"name": "location_id", "in": "path",
|
||||
"required": True, "schema": {"type": "integer"}},
|
||||
{
|
||||
"name": "location_type",
|
||||
"in": "path",
|
||||
"required": True,
|
||||
"schema": {"type": "string"},
|
||||
},
|
||||
{
|
||||
"name": "location_id",
|
||||
"in": "path",
|
||||
"required": True,
|
||||
"schema": {"type": "integer"},
|
||||
},
|
||||
],
|
||||
responses={200: OpenApiTypes.OBJECT, 404: OpenApiTypes.OBJECT},
|
||||
tags=["Maps"],
|
||||
@@ -87,25 +127,29 @@ class MapLocationDetailAPIView(APIView):
|
||||
|
||||
permission_classes = [AllowAny]
|
||||
|
||||
def get(self, request: HttpRequest, location_type: str, location_id: int) -> Response:
|
||||
def get(
|
||||
self, request: HttpRequest, location_type: str, location_id: int
|
||||
) -> Response:
|
||||
"""Get detailed information for a specific location."""
|
||||
try:
|
||||
# Simple implementation to fix import error
|
||||
return Response({
|
||||
"status": "success",
|
||||
"message": f"Location detail for {location_type}/{location_id} - implementation needed",
|
||||
"data": {
|
||||
"location_type": location_type,
|
||||
"location_id": location_id
|
||||
return Response(
|
||||
{
|
||||
"status": "success",
|
||||
"message": f"Location detail for {location_type}/{location_id} - implementation needed",
|
||||
"data": {
|
||||
"location_type": location_type,
|
||||
"location_id": location_id,
|
||||
},
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Error in MapLocationDetailAPIView: {str(e)}", exc_info=True)
|
||||
return Response({
|
||||
"status": "error",
|
||||
"message": "Failed to retrieve location details"
|
||||
}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
|
||||
return Response(
|
||||
{"status": "error", "message": "Failed to retrieve location details"},
|
||||
status=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
||||
)
|
||||
|
||||
|
||||
@extend_schema_view(
|
||||
@@ -113,7 +157,12 @@ class MapLocationDetailAPIView(APIView):
|
||||
summary="Search map locations",
|
||||
description="Search locations by text query with optional bounds filtering.",
|
||||
parameters=[
|
||||
{"name": "q", "in": "query", "required": True, "schema": {"type": "string"}},
|
||||
{
|
||||
"name": "q",
|
||||
"in": "query",
|
||||
"required": True,
|
||||
"schema": {"type": "string"},
|
||||
},
|
||||
],
|
||||
responses={200: OpenApiTypes.OBJECT, 400: OpenApiTypes.OBJECT},
|
||||
tags=["Maps"],
|
||||
@@ -129,24 +178,29 @@ class MapSearchAPIView(APIView):
|
||||
try:
|
||||
query = request.GET.get("q", "").strip()
|
||||
if not query:
|
||||
return Response({
|
||||
"status": "error",
|
||||
"message": "Search query 'q' parameter is required"
|
||||
}, status=status.HTTP_400_BAD_REQUEST)
|
||||
return Response(
|
||||
{
|
||||
"status": "error",
|
||||
"message": "Search query 'q' parameter is required",
|
||||
},
|
||||
status=status.HTTP_400_BAD_REQUEST,
|
||||
)
|
||||
|
||||
# Simple implementation to fix import error
|
||||
return Response({
|
||||
"status": "success",
|
||||
"message": f"Search for '{query}' - implementation needed",
|
||||
"data": []
|
||||
})
|
||||
return Response(
|
||||
{
|
||||
"status": "success",
|
||||
"message": f"Search for '{query}' - implementation needed",
|
||||
"data": [],
|
||||
}
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Error in MapSearchAPIView: {str(e)}", exc_info=True)
|
||||
return Response({
|
||||
"status": "error",
|
||||
"message": "Search failed due to internal error"
|
||||
}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
|
||||
return Response(
|
||||
{"status": "error", "message": "Search failed due to internal error"},
|
||||
status=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
||||
)
|
||||
|
||||
|
||||
@extend_schema_view(
|
||||
@@ -154,10 +208,30 @@ class MapSearchAPIView(APIView):
|
||||
summary="Get locations within bounds",
|
||||
description="Get locations within specific geographic bounds.",
|
||||
parameters=[
|
||||
{"name": "north", "in": "query", "required": True, "schema": {"type": "number"}},
|
||||
{"name": "south", "in": "query", "required": True, "schema": {"type": "number"}},
|
||||
{"name": "east", "in": "query", "required": True, "schema": {"type": "number"}},
|
||||
{"name": "west", "in": "query", "required": True, "schema": {"type": "number"}},
|
||||
{
|
||||
"name": "north",
|
||||
"in": "query",
|
||||
"required": True,
|
||||
"schema": {"type": "number"},
|
||||
},
|
||||
{
|
||||
"name": "south",
|
||||
"in": "query",
|
||||
"required": True,
|
||||
"schema": {"type": "number"},
|
||||
},
|
||||
{
|
||||
"name": "east",
|
||||
"in": "query",
|
||||
"required": True,
|
||||
"schema": {"type": "number"},
|
||||
},
|
||||
{
|
||||
"name": "west",
|
||||
"in": "query",
|
||||
"required": True,
|
||||
"schema": {"type": "number"},
|
||||
},
|
||||
],
|
||||
responses={200: OpenApiTypes.OBJECT, 400: OpenApiTypes.OBJECT},
|
||||
tags=["Maps"],
|
||||
@@ -172,18 +246,23 @@ class MapBoundsAPIView(APIView):
|
||||
"""Get locations within specific geographic bounds."""
|
||||
try:
|
||||
# Simple implementation to fix import error
|
||||
return Response({
|
||||
"status": "success",
|
||||
"message": "Bounds query - implementation needed",
|
||||
"data": []
|
||||
})
|
||||
return Response(
|
||||
{
|
||||
"status": "success",
|
||||
"message": "Bounds query - implementation needed",
|
||||
"data": [],
|
||||
}
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Error in MapBoundsAPIView: {str(e)}", exc_info=True)
|
||||
return Response({
|
||||
"status": "error",
|
||||
"message": "Failed to retrieve locations within bounds"
|
||||
}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
|
||||
return Response(
|
||||
{
|
||||
"status": "error",
|
||||
"message": "Failed to retrieve locations within bounds",
|
||||
},
|
||||
status=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
||||
)
|
||||
|
||||
|
||||
@extend_schema_view(
|
||||
@@ -203,14 +282,12 @@ class MapStatsAPIView(APIView):
|
||||
"""Get map service statistics and performance metrics."""
|
||||
try:
|
||||
# Simple implementation to fix import error
|
||||
return Response({
|
||||
"status": "success",
|
||||
"data": {
|
||||
"total_locations": 0,
|
||||
"cache_hits": 0,
|
||||
"cache_misses": 0
|
||||
return Response(
|
||||
{
|
||||
"status": "success",
|
||||
"data": {"total_locations": 0, "cache_hits": 0, "cache_misses": 0},
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
return Response(
|
||||
@@ -242,10 +319,9 @@ class MapCacheAPIView(APIView):
|
||||
"""Clear all map cache (admin only)."""
|
||||
try:
|
||||
# Simple implementation to fix import error
|
||||
return Response({
|
||||
"status": "success",
|
||||
"message": "Map cache cleared successfully"
|
||||
})
|
||||
return Response(
|
||||
{"status": "success", "message": "Map cache cleared successfully"}
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
return Response(
|
||||
@@ -257,10 +333,9 @@ class MapCacheAPIView(APIView):
|
||||
"""Invalidate specific cache entries."""
|
||||
try:
|
||||
# Simple implementation to fix import error
|
||||
return Response({
|
||||
"status": "success",
|
||||
"message": "Cache invalidated successfully"
|
||||
})
|
||||
return Response(
|
||||
{"status": "success", "message": "Cache invalidated successfully"}
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
return Response(
|
||||
|
||||
Reference in New Issue
Block a user