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

@@ -301,9 +301,16 @@ class SocialProvidersAPIView(APIView):
def get(self, request: Request) -> Response:
from django.core.cache import cache
from django.core.exceptions import ObjectDoesNotExist
try:
# Check if django-allauth is available
try:
from allauth.socialaccount.models import SocialApp
except ImportError:
# django-allauth is not installed, return empty list
serializer = SocialProviderOutputSerializer([], many=True)
return Response(serializer.data)
site = get_current_site(request._request) # type: ignore[attr-defined]
# Cache key based on site and request host
@@ -319,12 +326,10 @@ class SocialProvidersAPIView(APIView):
providers_list = []
# Optimized query: filter by site and order by provider name
from allauth.socialaccount.models import SocialApp
try:
social_apps = SocialApp.objects.filter(sites=site).order_by("provider")
except ObjectDoesNotExist:
# If no social apps exist, return empty list
except Exception:
# If query fails (table doesn't exist, etc.), return empty list
social_apps = []
for social_app in social_apps:
@@ -367,6 +372,7 @@ class SocialProvidersAPIView(APIView):
"code": "SOCIAL_PROVIDERS_ERROR",
"message": "Unable to retrieve social providers",
"details": str(e) if str(e) else None,
"request_user": str(request.user) if hasattr(request, 'user') else "AnonymousUser",
},
"data": None,
},