mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2025-12-20 12:11:13 -05:00
Refactor API structure and add comprehensive user management features
- Restructure API v1 with improved serializers organization - Add user deletion requests and moderation queue system - Implement bulk moderation operations and permissions - Add user profile enhancements with display names and avatars - Expand ride and park API endpoints with better filtering - Add manufacturer API with detailed ride relationships - Improve authentication flows and error handling - Update frontend documentation and API specifications
This commit is contained in:
@@ -12,58 +12,52 @@ import os
|
||||
from celery import Celery
|
||||
|
||||
# Set the default Django settings module for the 'celery' program.
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.django.local')
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.django.local")
|
||||
|
||||
app = Celery('thrillwiki')
|
||||
app = Celery("thrillwiki")
|
||||
|
||||
# Get Redis URL from environment variable with fallback
|
||||
REDIS_URL = os.environ.get('REDIS_URL', 'redis://localhost:6379/1')
|
||||
REDIS_URL = os.environ.get("REDIS_URL", "redis://localhost:6379/1")
|
||||
|
||||
# Celery Configuration - set directly without loading from Django settings first
|
||||
app.conf.update(
|
||||
# Broker settings
|
||||
broker_url=REDIS_URL,
|
||||
result_backend=REDIS_URL,
|
||||
|
||||
# Task settings
|
||||
task_serializer='json',
|
||||
accept_content=['json'],
|
||||
result_serializer='json',
|
||||
timezone='America/New_York',
|
||||
task_serializer="json",
|
||||
accept_content=["json"],
|
||||
result_serializer="json",
|
||||
timezone="America/New_York",
|
||||
enable_utc=True,
|
||||
|
||||
# Worker settings
|
||||
worker_prefetch_multiplier=1,
|
||||
task_acks_late=True,
|
||||
worker_max_tasks_per_child=1000,
|
||||
|
||||
# Task routing
|
||||
task_routes={
|
||||
'apps.core.tasks.trending.*': {'queue': 'trending'},
|
||||
'apps.core.tasks.analytics.*': {'queue': 'analytics'},
|
||||
'apps.core.tasks.cache.*': {'queue': 'cache'},
|
||||
"apps.core.tasks.trending.*": {"queue": "trending"},
|
||||
"apps.core.tasks.analytics.*": {"queue": "analytics"},
|
||||
"apps.core.tasks.cache.*": {"queue": "cache"},
|
||||
},
|
||||
|
||||
# Beat schedule for periodic tasks
|
||||
beat_schedule={
|
||||
'calculate-trending-content': {
|
||||
'task': 'apps.core.tasks.trending.calculate_trending_content',
|
||||
'schedule': 300.0, # Every 5 minutes
|
||||
"calculate-trending-content": {
|
||||
"task": "apps.core.tasks.trending.calculate_trending_content",
|
||||
"schedule": 300.0, # Every 5 minutes
|
||||
},
|
||||
'warm-trending-cache': {
|
||||
'task': 'apps.core.tasks.trending.warm_trending_cache',
|
||||
'schedule': 900.0, # Every 15 minutes
|
||||
"warm-trending-cache": {
|
||||
"task": "apps.core.tasks.trending.warm_trending_cache",
|
||||
"schedule": 900.0, # Every 15 minutes
|
||||
},
|
||||
'cleanup-old-analytics': {
|
||||
'task': 'apps.core.tasks.analytics.cleanup_old_analytics',
|
||||
'schedule': 86400.0, # Daily
|
||||
"cleanup-old-analytics": {
|
||||
"task": "apps.core.tasks.analytics.cleanup_old_analytics",
|
||||
"schedule": 86400.0, # Daily
|
||||
},
|
||||
},
|
||||
|
||||
# Task result settings
|
||||
result_expires=3600, # 1 hour
|
||||
task_ignore_result=False,
|
||||
|
||||
# Error handling
|
||||
task_reject_on_worker_lost=True,
|
||||
task_soft_time_limit=300, # 5 minutes
|
||||
@@ -77,4 +71,4 @@ app.autodiscover_tasks()
|
||||
@app.task(bind=True)
|
||||
def debug_task(self):
|
||||
"""Debug task for testing Celery setup."""
|
||||
print(f'Request: {self.request!r}')
|
||||
print(f"Request: {self.request!r}")
|
||||
|
||||
@@ -17,7 +17,6 @@ DATABASE_URL = config("DATABASE_URL")
|
||||
CACHE_URL = config("CACHE_URL", default="locmem://")
|
||||
EMAIL_URL = config("EMAIL_URL", default="console://")
|
||||
REDIS_URL = config("REDIS_URL", default="redis://127.0.0.1:6379/1")
|
||||
CORS_ALLOW_ALL_ORIGINS = config("CORS_ALLOW_ALL_ORIGINS", default=False, cast=bool)
|
||||
CORS_ALLOWED_ORIGINS = config("CORS_ALLOWED_ORIGINS", default=[])
|
||||
API_RATE_LIMIT_PER_MINUTE = config("API_RATE_LIMIT_PER_MINUTE", default=60)
|
||||
API_RATE_LIMIT_PER_HOUR = config("API_RATE_LIMIT_PER_HOUR", default=1000)
|
||||
@@ -47,8 +46,9 @@ SECRET_KEY = config("SECRET_KEY")
|
||||
ALLOWED_HOSTS = config("ALLOWED_HOSTS")
|
||||
|
||||
# CSRF trusted origins
|
||||
CSRF_TRUSTED_ORIGINS = config("CSRF_TRUSTED_ORIGINS",
|
||||
default=[]) # type: ignore[arg-type]
|
||||
CSRF_TRUSTED_ORIGINS = config(
|
||||
"CSRF_TRUSTED_ORIGINS", default=[]
|
||||
) # type: ignore[arg-type]
|
||||
|
||||
# Application definition
|
||||
DJANGO_APPS = [
|
||||
@@ -88,6 +88,7 @@ THIRD_PARTY_APPS = [
|
||||
"health_check.contrib.redis",
|
||||
"django_celery_beat", # Celery beat scheduler
|
||||
"django_celery_results", # Celery result backend
|
||||
"django_extensions", # Django Extensions for enhanced development tools
|
||||
]
|
||||
|
||||
LOCAL_APPS = [
|
||||
@@ -269,9 +270,9 @@ AUTH_USER_MODEL = "accounts.User"
|
||||
AUTOCOMPLETE_BLOCK_UNAUTHENTICATED = False
|
||||
|
||||
# Tailwind configuration
|
||||
TAILWIND_CLI_CONFIG_FILE = BASE_DIR / "tailwind.config.js"
|
||||
TAILWIND_CLI_SRC_CSS = BASE_DIR / "static" / "css" / "src" / "input.css"
|
||||
TAILWIND_CLI_DIST_CSS = BASE_DIR / "static" / "css" / "tailwind.css"
|
||||
TAILWIND_CLI_CONFIG_FILE = "tailwind.config.js"
|
||||
TAILWIND_CLI_SRC_CSS = "static/css/src/input.css"
|
||||
TAILWIND_CLI_DIST_CSS = "css/tailwind.css"
|
||||
|
||||
# Test runner
|
||||
TEST_RUNNER = "django.test.runner.DiscoverRunner"
|
||||
@@ -323,17 +324,19 @@ REST_FRAMEWORK = {
|
||||
}
|
||||
|
||||
# CORS Settings for API
|
||||
CORS_ALLOWED_ORIGINS = config("CORS_ALLOWED_ORIGINS",
|
||||
default=[]) # type: ignore[arg-type]
|
||||
|
||||
CORS_ALLOW_CREDENTIALS = True
|
||||
CORS_ALLOW_ALL_ORIGINS = config(
|
||||
"CORS_ALLOW_ALL_ORIGINS", default=False, cast=bool) # type: ignore[arg-type]
|
||||
"CORS_ALLOW_ALL_ORIGINS", default=False, cast=bool
|
||||
) # type: ignore[arg-type]
|
||||
|
||||
|
||||
API_RATE_LIMIT_PER_MINUTE = config(
|
||||
"API_RATE_LIMIT_PER_MINUTE", default=60, cast=int) # type: ignore[arg-type]
|
||||
"API_RATE_LIMIT_PER_MINUTE", default=60, cast=int
|
||||
) # type: ignore[arg-type]
|
||||
API_RATE_LIMIT_PER_HOUR = config(
|
||||
"API_RATE_LIMIT_PER_HOUR", default=1000, cast=int) # type: ignore[arg-type]
|
||||
"API_RATE_LIMIT_PER_HOUR", default=1000, cast=int
|
||||
) # type: ignore[arg-type]
|
||||
SPECTACULAR_SETTINGS = {
|
||||
"TITLE": "ThrillWiki API",
|
||||
"DESCRIPTION": "Comprehensive theme park and ride information API",
|
||||
|
||||
@@ -4,30 +4,7 @@ Local development settings for thrillwiki project.
|
||||
|
||||
from ..settings import database
|
||||
import logging
|
||||
from .base import (
|
||||
BASE_DIR,
|
||||
INSTALLED_APPS,
|
||||
MIDDLEWARE,
|
||||
STATIC_ROOT,
|
||||
STATIC_URL,
|
||||
ROOT_URLCONF,
|
||||
AUTH_PASSWORD_VALIDATORS,
|
||||
AUTH_USER_MODEL,
|
||||
TEMPLATES,
|
||||
SECRET_KEY,
|
||||
SPECTACULAR_SETTINGS,
|
||||
REST_FRAMEWORK,
|
||||
)
|
||||
|
||||
SECRET_KEY = SECRET_KEY
|
||||
SPECTACULAR_SETTINGS = SPECTACULAR_SETTINGS
|
||||
REST_FRAMEWORK = REST_FRAMEWORK
|
||||
TEMPLATES = TEMPLATES
|
||||
ROOT_URLCONF = ROOT_URLCONF
|
||||
AUTH_PASSWORD_VALIDATORS = AUTH_PASSWORD_VALIDATORS
|
||||
AUTH_USER_MODEL = AUTH_USER_MODEL
|
||||
STATIC_ROOT = STATIC_ROOT
|
||||
STATIC_URL = STATIC_URL
|
||||
from .base import *
|
||||
|
||||
# Import database configuration
|
||||
DATABASES = database.DATABASES
|
||||
|
||||
Reference in New Issue
Block a user