d74290036e
Cleaned up logout redirects Added suburbs admin page back. Wasn't able to create new suburbs Made active status check to any traveller save function
163 lines
5.1 KiB
Python
163 lines
5.1 KiB
Python
"""
|
|
Django settings for busManager project.
|
|
|
|
Generated by 'django-admin startproject' using Django 4.2.4.
|
|
|
|
For more information on this file, see
|
|
https://docs.djangoproject.com/en/4.2/topics/settings/
|
|
|
|
For the full list of settings and their values, see
|
|
https://docs.djangoproject.com/en/4.2/ref/settings/
|
|
"""
|
|
import os
|
|
from pathlib import Path
|
|
|
|
from dotenv import load_dotenv
|
|
|
|
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
|
BASE_DIR = Path(__file__).resolve().parent.parent
|
|
load_dotenv()
|
|
|
|
# Quick-start development settings - unsuitable for production
|
|
# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/
|
|
|
|
# SECURITY WARNING: keep the secret key used in production secret!
|
|
SECRET_KEY = os.environ.get('SECRET_KEY')
|
|
|
|
# SECURITY WARNING: don't run with debug turned on in production!
|
|
DEBUG = os.environ.get("DEBUG", default=False)
|
|
|
|
ALLOWED_HOSTS = os.environ.get('ALLOWED_HOSTS').split(' ')
|
|
|
|
# Application definition
|
|
|
|
INSTALLED_APPS = [
|
|
'coord.apps.CoordConfig',
|
|
# 'mail_templates.apps.MailTemplatesConfig',
|
|
'custom_user.apps.CustomUserConfig',
|
|
'django.contrib.admin',
|
|
'django.contrib.auth',
|
|
'django.contrib.contenttypes',
|
|
'django.contrib.sessions',
|
|
'django.contrib.messages',
|
|
'django.contrib.staticfiles',
|
|
'import_export',
|
|
'rangefilter',
|
|
]
|
|
|
|
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 = [
|
|
'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',
|
|
]
|
|
|
|
if "AZURE_CLIENT_ID" in os.environ:
|
|
AUTHENTICATION_BACKENDS = ("custom_user.backends.AzureBackend",)
|
|
MIDDLEWARE.append('custom_user.middleware.AzureMiddleware')
|
|
LOGIN_URL = "/auth/login"
|
|
LOGOUT_REDIRECT_URL = "/auth/logout"
|
|
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'
|
|
|
|
TEMPLATES = [
|
|
{
|
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
|
'DIRS': [BASE_DIR / "busManager/templates"],
|
|
'APP_DIRS': True,
|
|
'OPTIONS': {
|
|
'context_processors': [
|
|
'django.template.context_processors.debug',
|
|
'django.template.context_processors.request',
|
|
'django.contrib.auth.context_processors.auth',
|
|
'django.contrib.messages.context_processors.messages',
|
|
],
|
|
},
|
|
},
|
|
]
|
|
|
|
WSGI_APPLICATION = 'busManager.wsgi.application'
|
|
|
|
|
|
# Database
|
|
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases
|
|
|
|
DATABASES = {
|
|
"default": {
|
|
"ENGINE": os.environ.get("SQL_ENGINE", "django.db.backends.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
|
|
# https://docs.djangoproject.com/en/4.2/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',
|
|
},
|
|
]
|
|
|
|
# Internationalization
|
|
# https://docs.djangoproject.com/en/4.2/topics/i18n/
|
|
|
|
LANGUAGE_CODE = 'en-us'
|
|
|
|
TIME_ZONE = 'Australia/Melbourne'
|
|
|
|
USE_I18N = True
|
|
|
|
USE_TZ = True
|
|
|
|
|
|
# Static files (CSS, JavaScript, Images)
|
|
# https://docs.djangoproject.com/en/4.2/howto/static-files/
|
|
|
|
STATIC_URL = 'static/'
|
|
STATIC_ROOT = os.environ.get("STATIC_ROOT", None)
|
|
STATIC_MEDIA = os.environ.get("STATIC_MEDIA", None)
|
|
|
|
# Default primary key field type
|
|
# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field
|
|
|
|
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|