latest changes
This commit is contained in:
@@ -12,25 +12,42 @@ https://docs.djangoproject.com/en/6.1/ref/settings/
|
||||
|
||||
import os
|
||||
from pathlib import Path
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
|
||||
# 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.1/howto/deployment/checklist/
|
||||
def _local_env(name):
|
||||
if name in os.environ:
|
||||
return os.environ[name]
|
||||
path = BASE_DIR.parent / '.env'
|
||||
try:
|
||||
lines = path.read_text(encoding='utf-8').splitlines()
|
||||
except FileNotFoundError:
|
||||
return ''
|
||||
for line in lines:
|
||||
key, separator, value = line.strip().partition('=')
|
||||
if separator and key == name:
|
||||
return value.strip().strip('"\'')
|
||||
return ''
|
||||
|
||||
# SECURITY WARNING: keep the secret key used in production secret!
|
||||
SECRET_KEY = 'django-insecure-x%2-iw9@k2s1td)7m7-ww55w1x(5lh$j*luk8_fbytb-36il%t'
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = True
|
||||
DEBUG = _local_env('DJANGO_DEBUG').lower() in {'1', 'true', 'yes'}
|
||||
SECRET_KEY = _local_env('DJANGO_SECRET_KEY')
|
||||
TASKNEST_DEMO_PASSWORD = _local_env('TASKNEST_DEMO_PASSWORD')
|
||||
if not SECRET_KEY:
|
||||
raise ImproperlyConfigured('Set DJANGO_SECRET_KEY in the environment or ignored .env file.')
|
||||
SESSION_COOKIE_SECURE = not DEBUG
|
||||
CSRF_COOKIE_SECURE = not DEBUG
|
||||
SECURE_SSL_REDIRECT = not DEBUG
|
||||
|
||||
ALLOWED_HOSTS = ["localhost", "127.0.0.1", "tasksnest.jorendegraaf.eu"]
|
||||
SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")
|
||||
CSRF_TRUSTED_ORIGINS = [
|
||||
"https://tasksnest.jorendegraaf.eu",
|
||||
]
|
||||
CSRF_FAILURE_VIEW = 'planner.csrf.csrf_failure'
|
||||
|
||||
# Application definition
|
||||
|
||||
@@ -45,6 +62,7 @@ INSTALLED_APPS = [
|
||||
'planner',
|
||||
'food.apps.FoodConfig',
|
||||
'recipes',
|
||||
'groceries',
|
||||
'stress',
|
||||
'dreams',
|
||||
]
|
||||
@@ -55,10 +73,12 @@ RECIPE_MATCH_DEMO_USERNAME = os.environ.get('TASKNEST_RECIPE_MATCH_DEMO_USERNAME
|
||||
MIDDLEWARE = [
|
||||
'food.api_middleware.ApiErrorMiddleware',
|
||||
'django.middleware.security.SecurityMiddleware',
|
||||
'whitenoise.middleware.WhiteNoiseMiddleware',
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
'django.middleware.csrf.CsrfViewMiddleware',
|
||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
'planner.middleware_demo.DemoAccountPolicyMiddleware',
|
||||
'planner.middleware.UserTimezoneMiddleware',
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||
@@ -87,6 +107,8 @@ OAUTH2_PROVIDER = {
|
||||
'DCR_ENABLED': False,
|
||||
'OAUTH2_GRANT_TYPES_SUPPORTED': ['authorization_code', 'refresh_token'],
|
||||
'OAUTH2_TOKEN_ENDPOINT_AUTH_METHODS_SUPPORTED': ['none', 'client_secret_basic', 'client_secret_post'],
|
||||
'ALLOWED_REDIRECT_URI_SCHEMES': ['http', 'https'] if DEBUG else ['https'],
|
||||
'COMPLIANT_BCP_RFC9700_REDIRECT_URI_SCHEME': not DEBUG,
|
||||
'COMPLIANT_BCP_RFC9700_TOKEN_STORAGE': True,
|
||||
'COMPLIANT_BCP_RFC9700_PKCE_METHOD': True,
|
||||
'COMPLIANT_BCP_RFC9700_PKCE_REQUIRED': True,
|
||||
@@ -109,6 +131,7 @@ TEMPLATES = [
|
||||
'django.contrib.auth.context_processors.auth',
|
||||
'django.contrib.messages.context_processors.messages',
|
||||
'planner.context_processors.appearance',
|
||||
'planner.context_processors.navigation',
|
||||
],
|
||||
},
|
||||
},
|
||||
@@ -163,6 +186,7 @@ USE_TZ = True
|
||||
# https://docs.djangoproject.com/en/6.1/howto/static-files/
|
||||
|
||||
STATIC_URL = 'static/'
|
||||
STATIC_ROOT = BASE_DIR / 'staticfiles'
|
||||
MEDIA_ROOT = BASE_DIR / 'private_media'
|
||||
|
||||
# Vite writes built assets and its manifest here. Use the Vite server only when
|
||||
|
||||
@@ -27,6 +27,7 @@ urlpatterns = [
|
||||
path('admin/', admin.site.urls),
|
||||
path('food/', include('food.urls', namespace='food')),
|
||||
path('recipes/', include('recipes.urls', namespace='recipes')),
|
||||
path('groceries/', include('groceries.urls', namespace='groceries')),
|
||||
path('stress/', include('stress.urls', namespace='stress')),
|
||||
path('dreams/', include('dreams.urls', namespace='dreams')),
|
||||
path('', include('planner.urls')),
|
||||
|
||||
Reference in New Issue
Block a user