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:
pacnpal
2025-08-30 21:20:25 -04:00
parent fb6726f89a
commit 9bed782784
75 changed files with 4571 additions and 1962 deletions

View File

@@ -53,8 +53,9 @@ CACHES = {
CACHE_MIDDLEWARE_SECONDS = 1 # Very short cache for development
CACHE_MIDDLEWARE_KEY_PREFIX = "thrillwiki_dev"
# Development email backend
EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
# Development email backend - Use ForwardEmail for actual email sending
# EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend" # Console for debugging
EMAIL_BACKEND = "django_forwardemail.backends.ForwardEmailBackend" # Actual email sending
# Security settings for development
SECURE_SSL_REDIRECT = False
@@ -63,7 +64,7 @@ CSRF_COOKIE_SECURE = False
# Development monitoring tools
DEVELOPMENT_APPS = [
"silk",
# "silk", # Disabled for performance
"nplusone.ext.django",
"django_extensions",
"widget_tweaks",
@@ -76,11 +77,12 @@ for app in DEVELOPMENT_APPS:
# Development middleware
DEVELOPMENT_MIDDLEWARE = [
"silk.middleware.SilkyMiddleware",
# "silk.middleware.SilkyMiddleware", # Disabled for performance
"nplusone.ext.django.NPlusOneMiddleware",
"core.middleware.performance_middleware.PerformanceMiddleware",
"core.middleware.performance_middleware.QueryCountMiddleware",
"core.middleware.nextjs.APIResponseMiddleware", # Add this
"core.middleware.request_logging.RequestLoggingMiddleware", # Request logging
]
# Add development middleware
@@ -91,19 +93,7 @@ for middleware in DEVELOPMENT_MIDDLEWARE:
# Debug toolbar configuration
INTERNAL_IPS = ["127.0.0.1", "::1"]
# Silk configuration for development
# Disable profiler to avoid silk_profile installation issues
SILKY_PYTHON_PROFILER = False
SILKY_PYTHON_PROFILER_BINARY = False # Disable binary profiler
SILKY_PYTHON_PROFILER_RESULT_PATH = (
BASE_DIR / "profiles"
) # Not needed when profiler is disabled
SILKY_AUTHENTICATION = True # Require login to access Silk
SILKY_AUTHORISATION = True # Enable authorization
SILKY_MAX_REQUEST_BODY_SIZE = -1 # Don't limit request body size
# Limit response body size to 1KB for performance
SILKY_MAX_RESPONSE_BODY_SIZE = 1024
SILKY_META = True # Record metadata about requests
# Silk configuration disabled for performance
# NPlusOne configuration
NPLUSONE_LOGGER = logging.getLogger("nplusone")
@@ -153,22 +143,22 @@ LOGGING = {
"loggers": {
"django": {
"handlers": ["file"],
"level": "INFO",
"level": "WARNING", # Reduced from INFO
"propagate": False,
},
"django.db.backends": {
"handlers": ["console"],
"level": "DEBUG",
"level": "WARNING", # Reduced from DEBUG
"propagate": False,
},
"thrillwiki": {
"handlers": ["console", "file"],
"level": "DEBUG",
"level": "INFO", # Reduced from DEBUG
"propagate": False,
},
"performance": {
"handlers": ["performance"],
"level": "INFO",
"level": "WARNING", # Reduced from INFO
"propagate": False,
},
"query_optimization": {
@@ -178,7 +168,12 @@ LOGGING = {
},
"nplusone": {
"handlers": ["console"],
"level": "WARNING",
"level": "ERROR", # Reduced from WARNING
"propagate": False,
},
"request_logging": {
"handlers": ["console"],
"level": "INFO",
"propagate": False,
},
},