2026-01-13 20:58:05 -05:00
|
|
|
"""
|
|
|
|
|
Django settings for core project.
|
|
|
|
|
|
|
|
|
|
Generated by 'django-admin startproject' using Django 6.0.
|
|
|
|
|
|
|
|
|
|
For more information on this file, see
|
|
|
|
|
https://docs.djangoproject.com/en/6.0/topics/settings/
|
|
|
|
|
|
|
|
|
|
For the full list of settings and their values, see
|
|
|
|
|
https://docs.djangoproject.com/en/6.0/ref/settings/
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
from pathlib import Path
|
2026-02-18 20:18:56 -05:00
|
|
|
import dj_database_url
|
2026-03-02 15:45:12 -05:00
|
|
|
import os
|
|
|
|
|
import sys
|
|
|
|
|
if 'test' in sys.argv:
|
|
|
|
|
COMPRESS_ENABLED = False
|
2026-01-13 20:58:05 -05:00
|
|
|
|
|
|
|
|
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
|
|
|
|
BASE_DIR = Path(__file__).resolve().parent.parent
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Quick-start development settings - unsuitable for production
|
|
|
|
|
# See https://docs.djangoproject.com/en/6.0/howto/deployment/checklist/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# SECURITY WARNING: don't run with debug turned on in production!
|
|
|
|
|
if 'DJANGO_DEBUG_FALSE' in os.environ:
|
|
|
|
|
DEBUG = False
|
|
|
|
|
SECRET_KEY = os.environ['DJANGO_SECRET_KEY']
|
|
|
|
|
ALLOWED_HOSTS = [host.strip() for host in os.environ['DJANGO_ALLOWED_HOST'].split(',')]
|
2026-02-18 23:32:43 -05:00
|
|
|
CSRF_TRUSTED_ORIGINS = [f'https://{host.strip()}' for host in os.environ['DJANGO_ALLOWED_HOST'].split(',')]
|
2026-02-20 13:33:11 -05:00
|
|
|
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
|
|
|
|
|
SESSION_COOKIE_SECURE = True
|
|
|
|
|
CSRF_COOKIE_SECURE = True
|
|
|
|
|
SECURE_HSTS_SECONDS = 60
|
|
|
|
|
SECURE_HSTS_INCLUDE_SUBDOMAINS = True
|
|
|
|
|
SECURE_HSTS_PRELOAD = True
|
2026-03-02 16:02:47 -05:00
|
|
|
COMPRESS_OFFLINE = True
|
2026-01-13 20:58:05 -05:00
|
|
|
else:
|
|
|
|
|
DEBUG = True
|
|
|
|
|
# SECURITY WARNING: keep the secret key used in production secret!
|
|
|
|
|
SECRET_KEY = 'django-insecure-&9b_h=qpjy=sshhnsyg98&jp7(t6*v78__y%h2l$b#_@6z$-9r'
|
|
|
|
|
ALLOWED_HOSTS = []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Application definition
|
|
|
|
|
|
|
|
|
|
INSTALLED_APPS = [
|
|
|
|
|
# Django apps
|
2026-02-19 20:31:29 -05:00
|
|
|
'django.contrib.admin',
|
2026-01-13 20:58:05 -05:00
|
|
|
'django.contrib.auth',
|
|
|
|
|
'django.contrib.contenttypes',
|
|
|
|
|
'django.contrib.sessions',
|
|
|
|
|
'django.contrib.messages',
|
|
|
|
|
'django.contrib.staticfiles',
|
|
|
|
|
# Custom apps
|
|
|
|
|
'apps.dashboard',
|
2026-01-30 15:04:47 -05:00
|
|
|
'apps.lyric',
|
2026-02-20 16:37:48 -05:00
|
|
|
'apps.api',
|
2026-02-03 22:14:55 -05:00
|
|
|
'functional_tests',
|
2026-01-13 20:58:05 -05:00
|
|
|
# Depend apps
|
2026-03-02 13:57:03 -05:00
|
|
|
'compressor',
|
2026-02-20 16:37:48 -05:00
|
|
|
'rest_framework',
|
2026-01-13 20:58:05 -05:00
|
|
|
]
|
|
|
|
|
|
2026-02-03 22:14:55 -05:00
|
|
|
# if 'DJANGO_DEBUG_FALSE' not in os.environ:
|
|
|
|
|
# INSTALLED_APPS += ['functional_tests']
|
2026-02-03 14:54:37 -05:00
|
|
|
|
2026-01-13 20:58:05 -05:00
|
|
|
MIDDLEWARE = [
|
|
|
|
|
'django.middleware.security.SecurityMiddleware',
|
2026-02-08 17:55:09 -05:00
|
|
|
'whitenoise.middleware.WhiteNoiseMiddleware',
|
2026-01-13 20:58:05 -05:00
|
|
|
'django.contrib.sessions.middleware.SessionMiddleware',
|
|
|
|
|
'django.middleware.common.CommonMiddleware',
|
|
|
|
|
'django.middleware.csrf.CsrfViewMiddleware',
|
|
|
|
|
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
|
|
|
|
'django.contrib.messages.middleware.MessageMiddleware',
|
|
|
|
|
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
2026-03-04 15:13:16 -05:00
|
|
|
'django_htmx.middleware.HtmxMiddleware',
|
2026-01-13 20:58:05 -05:00
|
|
|
]
|
|
|
|
|
|
|
|
|
|
ROOT_URLCONF = 'core.urls'
|
|
|
|
|
|
|
|
|
|
TEMPLATES = [
|
|
|
|
|
{
|
|
|
|
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
|
|
|
|
'DIRS': [BASE_DIR / 'templates'],
|
|
|
|
|
'APP_DIRS': True,
|
|
|
|
|
'OPTIONS': {
|
|
|
|
|
'context_processors': [
|
|
|
|
|
'django.template.context_processors.request',
|
|
|
|
|
'django.contrib.auth.context_processors.auth',
|
|
|
|
|
'django.contrib.messages.context_processors.messages',
|
2026-03-05 14:45:55 -05:00
|
|
|
'core.context_processors.user_palette',
|
2026-01-13 20:58:05 -05:00
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
WSGI_APPLICATION = 'core.wsgi.application'
|
|
|
|
|
ASGI_APPLICATION = 'core.asgi.application'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Database
|
|
|
|
|
# https://docs.djangoproject.com/en/6.0/ref/settings/#databases
|
|
|
|
|
|
2026-02-18 20:18:56 -05:00
|
|
|
DATABASE_URL = os.environ.get('DATABASE_URL')
|
|
|
|
|
if DATABASE_URL:
|
|
|
|
|
DATABASES = {'default': dj_database_url.config(conn_max_age=600)}
|
|
|
|
|
else:
|
|
|
|
|
DATABASES = {
|
|
|
|
|
'default': {
|
|
|
|
|
'ENGINE': 'django.db.backends.sqlite3',
|
|
|
|
|
'NAME': BASE_DIR / 'db.sqlite3',
|
|
|
|
|
}
|
2026-01-13 20:58:05 -05:00
|
|
|
}
|
|
|
|
|
|
2026-02-21 23:13:23 -05:00
|
|
|
# Celery & Redis
|
2026-02-21 21:35:15 -05:00
|
|
|
CELERY_BROKER_URL = os.environ.get('CELERY_BROKER_URL', 'redis://localhost:6379/0')
|
2026-02-21 23:13:23 -05:00
|
|
|
REDIS_URL = os.environ.get('REDIS_URL')
|
|
|
|
|
if REDIS_URL:
|
|
|
|
|
CACHES = {
|
|
|
|
|
'default': {
|
|
|
|
|
'BACKEND': 'django.core.cache.backends.redis.RedisCache',
|
|
|
|
|
'LOCATION': REDIS_URL,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
SESSION_ENGINE = 'django.contrib.sessions.backends.cached_db'
|
2026-01-13 20:58:05 -05:00
|
|
|
|
|
|
|
|
# Password validation
|
|
|
|
|
# https://docs.djangoproject.com/en/6.0/ref/settings/#auth-password-validators
|
|
|
|
|
|
|
|
|
|
AUTH_PASSWORD_VALIDATORS = [
|
|
|
|
|
{
|
|
|
|
|
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
|
|
|
|
|
},
|
|
|
|
|
]
|
|
|
|
|
|
2026-01-30 15:04:47 -05:00
|
|
|
AUTH_USER_MODEL = "lyric.User"
|
|
|
|
|
|
2026-01-30 19:35:45 -05:00
|
|
|
AUTHENTICATION_BACKENDS = [
|
2026-02-19 20:31:29 -05:00
|
|
|
"django.contrib.auth.backends.ModelBackend",
|
2026-01-30 19:35:45 -05:00
|
|
|
"apps.lyric.authentication.PasswordlessAuthenticationBackend",
|
|
|
|
|
]
|
|
|
|
|
|
2026-01-13 20:58:05 -05:00
|
|
|
|
|
|
|
|
# Internationalization
|
|
|
|
|
# https://docs.djangoproject.com/en/6.0/topics/i18n/
|
|
|
|
|
|
|
|
|
|
LANGUAGE_CODE = 'en-us'
|
|
|
|
|
|
|
|
|
|
TIME_ZONE = 'UTC'
|
|
|
|
|
|
|
|
|
|
USE_I18N = True
|
|
|
|
|
|
|
|
|
|
USE_TZ = True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Static files (CSS, JavaScript, Images)
|
|
|
|
|
# https://docs.djangoproject.com/en/6.0/howto/static-files/
|
|
|
|
|
|
|
|
|
|
STATIC_URL = 'static/'
|
|
|
|
|
STATIC_ROOT = BASE_DIR / 'static'
|
2026-02-11 14:42:38 -05:00
|
|
|
STATICFILES_DIRS = [
|
|
|
|
|
BASE_DIR / 'static_src',
|
|
|
|
|
]
|
2026-03-02 13:57:03 -05:00
|
|
|
STATICFILES_FINDERS = [
|
|
|
|
|
'django.contrib.staticfiles.finders.FileSystemFinder',
|
|
|
|
|
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
|
|
|
|
|
'compressor.finders.CompressorFinder',
|
|
|
|
|
]
|
|
|
|
|
COMPRESS_PRECOMPILERS = [
|
|
|
|
|
('text/x-scss', 'django_libsass.SassCompiler'),
|
|
|
|
|
]
|
2026-01-13 20:58:05 -05:00
|
|
|
|
|
|
|
|
LOGGING = {
|
|
|
|
|
"version": 1,
|
|
|
|
|
"disable_existing_loggers": False,
|
|
|
|
|
"handlers": {
|
|
|
|
|
"console": {"class": "logging.StreamHandler"},
|
|
|
|
|
},
|
|
|
|
|
"loggers": {
|
|
|
|
|
"root": {"handlers": ["console"], "level": "INFO"},
|
|
|
|
|
},
|
|
|
|
|
}
|
2026-02-01 16:19:07 -05:00
|
|
|
|
2026-02-07 18:58:17 -05:00
|
|
|
# Mailgun API settings (for HTTP API instead of SMTP)
|
|
|
|
|
MAILGUN_API_KEY = os.environ.get("MAILGUN_API_KEY")
|
2026-02-18 23:04:21 -05:00
|
|
|
MAILGUN_DOMAIN = "howdy.earthmanrpg.com" # Your Mailgun domain
|