104 lines
2.8 KiB
Python
104 lines
2.8 KiB
Python
import os
|
|
from pathlib import Path
|
|
|
|
|
|
BASE_DIR = Path(__file__).resolve().parent.parent
|
|
REPO_ROOT = BASE_DIR.parent
|
|
DATA_ROOT = Path(os.environ.get("AXIA4_DATA_ROOT", REPO_ROOT / "DATA"))
|
|
|
|
|
|
def resolve_db_path() -> Path:
|
|
candidates = []
|
|
env_path = os.environ.get("AXIA4_DB_PATH")
|
|
if env_path:
|
|
candidates.append(Path(env_path))
|
|
candidates.extend([
|
|
Path("/DATA/axia4.sqlite"),
|
|
DATA_ROOT / "axia4.sqlite",
|
|
])
|
|
for candidate in candidates:
|
|
if candidate.exists():
|
|
return candidate
|
|
return candidates[-1]
|
|
|
|
|
|
SECRET_KEY = os.environ.get("DJANGO_SECRET_KEY", "axia4-dev-secret-key-change-me")
|
|
DEBUG = os.environ.get("DJANGO_DEBUG", "1") == "1"
|
|
ALLOWED_HOSTS = [host.strip() for host in os.environ.get("DJANGO_ALLOWED_HOSTS", "*").split(",") if host.strip()]
|
|
|
|
INSTALLED_APPS = [
|
|
"django.contrib.admin",
|
|
"django.contrib.auth",
|
|
"django.contrib.contenttypes",
|
|
"django.contrib.sessions",
|
|
"django.contrib.messages",
|
|
"django.contrib.staticfiles",
|
|
"core",
|
|
"account",
|
|
"aulatek",
|
|
"club",
|
|
"sysadmin",
|
|
]
|
|
|
|
MIDDLEWARE = [
|
|
"django.middleware.security.SecurityMiddleware",
|
|
"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",
|
|
"core.middleware.AxiaAuthMiddleware",
|
|
]
|
|
|
|
ROOT_URLCONF = "axia4_django.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",
|
|
"core.context_processors.axia4",
|
|
],
|
|
},
|
|
},
|
|
]
|
|
|
|
WSGI_APPLICATION = "axia4_django.wsgi.application"
|
|
ASGI_APPLICATION = "axia4_django.asgi.application"
|
|
|
|
DATABASES = {
|
|
"default": {
|
|
"ENGINE": "django.db.backends.sqlite3",
|
|
"NAME": resolve_db_path(),
|
|
}
|
|
}
|
|
|
|
AUTH_PASSWORD_VALIDATORS = []
|
|
|
|
LANGUAGE_CODE = "es-es"
|
|
TIME_ZONE = "Europe/Madrid"
|
|
USE_I18N = True
|
|
USE_TZ = True
|
|
|
|
STATIC_URL = "/static/"
|
|
STATICFILES_DIRS = [BASE_DIR / "static"]
|
|
MEDIA_URL = "/media/"
|
|
MEDIA_ROOT = DATA_ROOT / "attachments"
|
|
|
|
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
|
|
|
|
SESSION_COOKIE_SECURE = not DEBUG
|
|
CSRF_COOKIE_SECURE = not DEBUG
|
|
SESSION_COOKIE_SAMESITE = "Lax"
|
|
CSRF_COOKIE_SAMESITE = "Lax"
|
|
SESSION_COOKIE_AGE = 60 * 60 * 24 * 7
|
|
|
|
AXIA4_DATA_ROOT = DATA_ROOT
|
|
AXIA4_AUTH_COOKIE = "auth_token"
|