mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2025-12-20 12:51:09 -05:00
feat: Implement avatar upload system with Cloudflare integration
- Added migration to transition avatar data from CloudflareImageField to ForeignKey structure in UserProfile. - Fixed UserProfileEvent avatar field to align with new avatar structure. - Created serializers for social authentication, including connected and available providers. - Developed request logging middleware for comprehensive request/response logging. - Updated moderation and parks migrations to remove outdated triggers and adjust foreign key relationships. - Enhanced rides migrations to ensure proper handling of image uploads and triggers. - Introduced a test script for the 3-step avatar upload process, ensuring functionality with Cloudflare. - Documented the fix for avatar upload issues, detailing root cause, implementation, and verification steps. - Implemented automatic deletion of Cloudflare images upon avatar, park, and ride photo changes or removals.
This commit is contained in:
@@ -64,6 +64,8 @@ DJANGO_APPS = [
|
||||
]
|
||||
|
||||
THIRD_PARTY_APPS = [
|
||||
# Django Cloudflare Images Toolkit - moved to top to avoid circular imports
|
||||
"django_cloudflareimages_toolkit",
|
||||
"rest_framework", # Django REST Framework
|
||||
# Token authentication (kept for backward compatibility)
|
||||
"rest_framework.authtoken",
|
||||
@@ -103,7 +105,7 @@ LOCAL_APPS = [
|
||||
"apps.parks",
|
||||
"apps.rides",
|
||||
"api", # Centralized API app (located at backend/api/)
|
||||
"apps.email_service",
|
||||
"django_forwardemail", # New PyPI package for email service
|
||||
"apps.moderation",
|
||||
]
|
||||
|
||||
@@ -171,10 +173,30 @@ else:
|
||||
|
||||
WSGI_APPLICATION = "thrillwiki.wsgi.application"
|
||||
|
||||
# Cloudflare Images Settings
|
||||
# Cloudflare Images Settings - Updated for django-cloudflareimages-toolkit
|
||||
CLOUDFLARE_IMAGES = {
|
||||
'ACCOUNT_ID': config("CLOUDFLARE_IMAGES_ACCOUNT_ID"),
|
||||
'API_TOKEN': config("CLOUDFLARE_IMAGES_API_TOKEN"),
|
||||
'ACCOUNT_HASH': config("CLOUDFLARE_IMAGES_ACCOUNT_HASH"),
|
||||
|
||||
# Optional settings
|
||||
'DEFAULT_VARIANT': 'public',
|
||||
'UPLOAD_TIMEOUT': 300,
|
||||
'WEBHOOK_SECRET': config("CLOUDFLARE_IMAGES_WEBHOOK_SECRET", default=""),
|
||||
'CLEANUP_EXPIRED_HOURS': 24,
|
||||
'MAX_FILE_SIZE': 10 * 1024 * 1024, # 10MB
|
||||
'ALLOWED_FORMATS': ['jpeg', 'png', 'gif', 'webp'],
|
||||
'REQUIRE_SIGNED_URLS': False,
|
||||
'DEFAULT_METADATA': {},
|
||||
}
|
||||
|
||||
# Storage configuration
|
||||
STORAGES = {
|
||||
"default": {
|
||||
"BACKEND": "cloudflare_images.storage.CloudflareImagesStorage",
|
||||
"BACKEND": "django.core.files.storage.FileSystemStorage",
|
||||
"OPTIONS": {
|
||||
"location": str(BASE_DIR.parent / "shared" / "media"),
|
||||
},
|
||||
},
|
||||
"staticfiles": {
|
||||
"BACKEND": "django.contrib.staticfiles.storage.StaticFilesStorage",
|
||||
@@ -183,12 +205,6 @@ STORAGES = {
|
||||
},
|
||||
},
|
||||
}
|
||||
CLOUDFLARE_IMAGES_ACCOUNT_ID = config("CLOUDFLARE_IMAGES_ACCOUNT_ID")
|
||||
CLOUDFLARE_IMAGES_API_TOKEN = config("CLOUDFLARE_IMAGES_API_TOKEN")
|
||||
CLOUDFLARE_IMAGES_ACCOUNT_HASH = config("CLOUDFLARE_IMAGES_ACCOUNT_HASH")
|
||||
# CLOUDFLARE_IMAGES_DOMAIN should only be set if using a custom domain
|
||||
# When not set, it defaults to imagedelivery.net with the correct URL format
|
||||
# CLOUDFLARE_IMAGES_DOMAIN = config("CLOUDFLARE_IMAGES_DOMAIN", default=None)
|
||||
|
||||
# Password validation
|
||||
AUTH_PASSWORD_VALIDATORS = [
|
||||
@@ -299,6 +315,12 @@ ROADTRIP_BACKOFF_FACTOR = 2
|
||||
# Frontend URL Configuration
|
||||
FRONTEND_DOMAIN = config("FRONTEND_DOMAIN", default="https://thrillwiki.com")
|
||||
|
||||
# ForwardEmail Configuration
|
||||
FORWARD_EMAIL_BASE_URL = config(
|
||||
"FORWARD_EMAIL_BASE_URL", default="https://api.forwardemail.net")
|
||||
FORWARD_EMAIL_API_KEY = config("FORWARD_EMAIL_API_KEY", default="")
|
||||
FORWARD_EMAIL_DOMAIN = config("FORWARD_EMAIL_DOMAIN", default="")
|
||||
|
||||
# Django REST Framework Settings
|
||||
REST_FRAMEWORK = {
|
||||
"DEFAULT_AUTHENTICATION_CLASSES": [
|
||||
|
||||
Reference in New Issue
Block a user