feat(rides): populate slugs for existing RideModel records and ensure uniqueness

- Added migration 0011 to populate unique slugs for existing RideModel records based on manufacturer and model names.
- Implemented logic to ensure slug uniqueness during population.
- Added reverse migration to clear slugs if needed.

feat(rides): enforce unique slugs for RideModel

- Created migration 0012 to alter the slug field in RideModel to be unique.
- Updated the slug field to include help text and a maximum length of 255 characters.

docs: integrate Cloudflare Images into rides and parks models

- Updated RidePhoto and ParkPhoto models to use CloudflareImagesField for image storage.
- Enhanced API serializers for rides and parks to support Cloudflare Images, including new fields for image URLs and variants.
- Provided comprehensive OpenAPI schema metadata for new fields.
- Documented database migrations for the integration.
- Detailed configuration settings for Cloudflare Images.
- Updated API response formats to include Cloudflare Images URLs and variants.
- Added examples for uploading photos via API and outlined testing procedures.
This commit is contained in:
pacnpal
2025-08-28 15:12:39 -04:00
parent 715e284b3e
commit 67db0aa46e
34 changed files with 6002 additions and 894 deletions

View File

@@ -137,6 +137,37 @@ def custom_exception_handler(
)
response = Response(custom_response_data, status=status.HTTP_403_FORBIDDEN)
# Catch-all for any other exceptions that might slip through
# This ensures we ALWAYS return JSON for API endpoints
else:
# Check if this is an API request by looking at the URL path
request = context.get("request")
if request and hasattr(request, "path") and "/api/" in request.path:
# This is an API request, so we must return JSON
custom_response_data = {
"status": "error",
"error": {
"code": exc.__class__.__name__.upper(),
"message": str(exc) if str(exc) else "An unexpected error occurred",
"details": None,
},
"data": None,
}
# Add request context for debugging
if hasattr(request, "user"):
custom_response_data["error"]["request_user"] = str(request.user)
# Log the error for monitoring
log_exception(
logger,
exc,
context={"response_status": status.HTTP_500_INTERNAL_SERVER_ERROR},
request=request,
)
response = Response(custom_response_data, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
return response