Replacing template with base settings.py
This commit is contained in:
@@ -9,29 +9,31 @@ https://docs.djangoproject.com/en/4.2/topics/settings/
|
|||||||
For the full list of settings and their values, see
|
For the full list of settings and their values, see
|
||||||
https://docs.djangoproject.com/en/4.2/ref/settings/
|
https://docs.djangoproject.com/en/4.2/ref/settings/
|
||||||
"""
|
"""
|
||||||
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
from dotenv import load_dotenv
|
||||||
|
|
||||||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||||
|
load_dotenv()
|
||||||
|
|
||||||
# Quick-start development settings - unsuitable for production
|
# Quick-start development settings - unsuitable for production
|
||||||
# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/
|
# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/
|
||||||
|
|
||||||
# SECURITY WARNING: keep the secret key used in production secret!
|
# SECURITY WARNING: keep the secret key used in production secret!
|
||||||
SECRET_KEY = ''
|
SECRET_KEY = os.environ.get('SECRET_KEY')
|
||||||
|
|
||||||
# SECURITY WARNING: don't run with debug turned on in production!
|
# SECURITY WARNING: don't run with debug turned on in production!
|
||||||
DEBUG = False
|
DEBUG = os.environ.get("DEBUG", default=False)
|
||||||
|
|
||||||
ALLOWED_HOSTS = ['*']
|
|
||||||
|
|
||||||
|
ALLOWED_HOSTS = os.environ.get('ALLOWED_HOSTS').split(' ')
|
||||||
|
|
||||||
# Application definition
|
# Application definition
|
||||||
|
|
||||||
INSTALLED_APPS = [
|
INSTALLED_APPS = [
|
||||||
'coord.apps.CoordConfig',
|
'coord.apps.CoordConfig',
|
||||||
|
'mail_templates.apps.MailTemplatesConfig',
|
||||||
'django.contrib.admin',
|
'django.contrib.admin',
|
||||||
'django.contrib.auth',
|
'django.contrib.auth',
|
||||||
'django.contrib.contenttypes',
|
'django.contrib.contenttypes',
|
||||||
@@ -39,8 +41,19 @@ INSTALLED_APPS = [
|
|||||||
'django.contrib.messages',
|
'django.contrib.messages',
|
||||||
'django.contrib.staticfiles',
|
'django.contrib.staticfiles',
|
||||||
'import_export',
|
'import_export',
|
||||||
|
'rangefilter',
|
||||||
|
'azure_auth',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
TWILIO = {
|
||||||
|
"ACCOUNT_SID": os.environ.get('TWILIO_SID'),
|
||||||
|
"AUTH_TOKEN": os.environ.get('TWILIO_TOKEN'),
|
||||||
|
"SENDER": os.environ.get("TWILIO_SENDER")
|
||||||
|
}
|
||||||
|
|
||||||
|
LOGIN_URL = "/login"
|
||||||
|
LOGIN_REDIRECT_URL = "/"
|
||||||
|
|
||||||
MIDDLEWARE = [
|
MIDDLEWARE = [
|
||||||
'django.middleware.security.SecurityMiddleware',
|
'django.middleware.security.SecurityMiddleware',
|
||||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||||
@@ -51,6 +64,21 @@ MIDDLEWARE = [
|
|||||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
if "AZURE_CLIENT_ID" in os.environ:
|
||||||
|
AUTHENTICATION_BACKENDS = ("azure_auth.backends.AzureBackend",)
|
||||||
|
MIDDLEWARE.append('azure_auth.middleware.AzureMiddleware')
|
||||||
|
LOGIN_URL = "/azure_auth/login"
|
||||||
|
AZURE_AUTH = {
|
||||||
|
"CLIENT_ID": os.environ.get('AZURE_CLIENT_ID'),
|
||||||
|
"CLIENT_SECRET": os.environ.get('AZURE_CLIENT_SECRET'),
|
||||||
|
"REDIRECT_URI": os.environ.get('AZURE_REDIRECT_URI'),
|
||||||
|
"SCOPES": ["User.Read"],
|
||||||
|
"AUTHORITY": os.environ.get('AZURE_AUTHORITY', default='https://login.microsoftonline.com/common'), # Or https://login.microsoftonline.com/common if multi-tenant
|
||||||
|
# "LOGOUT_URI": "https://<domain>/logout", # Optional
|
||||||
|
# "PUBLIC_URLS": ["<public:view_name>",], # Optional, public views accessible by non-authenticated users
|
||||||
|
# "PUBLIC_PATHS": ['/go/',], # Optional, public paths accessible by non-authenticated users
|
||||||
|
}
|
||||||
|
|
||||||
ROOT_URLCONF = 'busManager.urls'
|
ROOT_URLCONF = 'busManager.urls'
|
||||||
|
|
||||||
TEMPLATES = [
|
TEMPLATES = [
|
||||||
@@ -76,12 +104,19 @@ WSGI_APPLICATION = 'busManager.wsgi.application'
|
|||||||
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases
|
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases
|
||||||
|
|
||||||
DATABASES = {
|
DATABASES = {
|
||||||
'default': {
|
"default": {
|
||||||
'ENGINE': 'django.db.backends.sqlite3',
|
"ENGINE": os.environ.get("SQL_ENGINE", "django.db.backends.sqlite3"),
|
||||||
'NAME': BASE_DIR / 'db.sqlite3',
|
"NAME": os.environ.get("SQL_DATABASE", BASE_DIR / "db.sqlite3"),
|
||||||
|
"USER": os.environ.get("SQL_USER", "user"),
|
||||||
|
"PASSWORD": os.environ.get("SQL_PASSWORD", "password"),
|
||||||
|
"HOST": os.environ.get("SQL_HOST", "localhost"),
|
||||||
|
"PORT": os.environ.get("SQL_PORT", "5432"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
|
||||||
|
EMAIL_HOST = os.environ.get("EMAIL_HOST")
|
||||||
|
EMAIL_PORT = os.environ.get("EMAIL_PORT")
|
||||||
|
|
||||||
# Password validation
|
# Password validation
|
||||||
# https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators
|
# https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators
|
||||||
@@ -101,7 +136,6 @@ AUTH_PASSWORD_VALIDATORS = [
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
# Internationalization
|
# Internationalization
|
||||||
# https://docs.djangoproject.com/en/4.2/topics/i18n/
|
# https://docs.djangoproject.com/en/4.2/topics/i18n/
|
||||||
|
|
||||||
@@ -118,6 +152,8 @@ USE_TZ = True
|
|||||||
# https://docs.djangoproject.com/en/4.2/howto/static-files/
|
# https://docs.djangoproject.com/en/4.2/howto/static-files/
|
||||||
|
|
||||||
STATIC_URL = 'static/'
|
STATIC_URL = 'static/'
|
||||||
|
STATIC_ROOT = os.environ.get("STATIC_ROOT", None)
|
||||||
|
STATIC_MEDIA = os.environ.get("STATIC_MEDIA", None)
|
||||||
|
|
||||||
# Default primary key field type
|
# Default primary key field type
|
||||||
# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field
|
# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field
|
||||||
Reference in New Issue
Block a user