209 lines
5.5 KiB
Python
209 lines
5.5 KiB
Python
"""
|
|
Django settings for konova project.
|
|
|
|
Generated by 'django-admin startproject' using Django 3.1.3.
|
|
|
|
For more information on this file, see
|
|
https://docs.djangoproject.com/en/3.1/topics/settings/
|
|
|
|
For the full list of settings and their values, see
|
|
https://docs.djangoproject.com/en/3.1/ref/settings/
|
|
"""
|
|
import os
|
|
|
|
import environ
|
|
from django.utils.translation import gettext_lazy as _
|
|
from django.conf.locale.de import formats as de_formats
|
|
|
|
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
|
BASE_DIR = os.path.dirname(
|
|
os.path.dirname(
|
|
os.path.dirname(
|
|
os.path.abspath(
|
|
__file__
|
|
)
|
|
)
|
|
)
|
|
)
|
|
|
|
env = environ.Env()
|
|
# Take environment variables from .env.dev file
|
|
environ.Env.read_env(os.path.join(BASE_DIR, '.env'))
|
|
|
|
# SECURITY WARNING: keep the secret key used in production secret!
|
|
SECRET_KEY = env("SECRET_KEY")
|
|
|
|
# SECURITY WARNING: don't run with debug turned on in production!
|
|
DEBUG = env.bool("DEBUG", default=False)
|
|
|
|
ADMINS = [x.split(':') for x in env.list('ADMINS')]
|
|
|
|
ALLOWED_HOSTS = env.list("ALLOWED_HOSTS")
|
|
|
|
BASE_URL = env("BASE_URL")
|
|
|
|
CSRF_TRUSTED_ORIGINS = [
|
|
BASE_URL
|
|
]
|
|
|
|
# Authentication settings
|
|
LOGIN_URL = "/oauth/login/"
|
|
|
|
# Session settings
|
|
SESSION_COOKIE_AGE = 60 * 60 # 60 minutes
|
|
SESSION_SAVE_EVERY_REQUEST = True
|
|
|
|
# Application definition
|
|
|
|
INSTALLED_APPS = [
|
|
'dal',
|
|
'dal_select2',
|
|
'django.contrib.admin',
|
|
'django.contrib.auth',
|
|
'django.contrib.contenttypes',
|
|
'django.contrib.sessions',
|
|
'django.contrib.messages',
|
|
'django.contrib.staticfiles',
|
|
'django.contrib.gis',
|
|
'django.contrib.humanize',
|
|
'simple_sso.sso_server',
|
|
'django_tables2',
|
|
'bootstrap_modal_forms',
|
|
'fontawesome_5',
|
|
'bootstrap4',
|
|
'konova',
|
|
'compensation',
|
|
'intervention',
|
|
'news',
|
|
'user',
|
|
'ema',
|
|
'codelist',
|
|
'analysis',
|
|
'api',
|
|
]
|
|
|
|
MIDDLEWARE = [
|
|
'django.middleware.security.SecurityMiddleware',
|
|
'django.contrib.sessions.middleware.SessionMiddleware',
|
|
"django.middleware.locale.LocaleMiddleware",
|
|
'django.middleware.common.CommonMiddleware',
|
|
'django.middleware.csrf.CsrfViewMiddleware',
|
|
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
|
'django.contrib.messages.middleware.MessageMiddleware',
|
|
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
|
]
|
|
|
|
ROOT_URLCONF = 'konova.urls'
|
|
|
|
TEMPLATES = [
|
|
{
|
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
|
'DIRS': [
|
|
os.path.join(BASE_DIR, "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 = 'konova.wsgi.application'
|
|
|
|
|
|
# Database
|
|
# https://docs.djangoproject.com/en/3.1/ref/settings/#databases
|
|
DATABASES = {
|
|
'default': {
|
|
'ENGINE': 'django.contrib.gis.db.backends.postgis',
|
|
'NAME': env("DB_NAME"),
|
|
'USER': env("DB_USER"),
|
|
'PASSWORD': env("DB_PASSWORD"),
|
|
'HOST': env("DB_HOST"),
|
|
'PORT': env("DB_PORT"),
|
|
}
|
|
}
|
|
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
|
|
|
|
# Password validation
|
|
# https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators
|
|
AUTH_USER_MODEL = "user.User"
|
|
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/3.1/topics/i18n/
|
|
|
|
LANGUAGE_CODE = 'de'
|
|
LANGUAGES = [
|
|
('de', _('German')),
|
|
('en', _('English')),
|
|
]
|
|
|
|
USE_THOUSAND_SEPARATOR = True
|
|
|
|
# Regular python relevant date/datetime formatting
|
|
DEFAULT_DATE_TIME_FORMAT = '%d.%m.%Y %H:%M:%S'
|
|
DEFAULT_DATE_FORMAT = '%d.%m.%Y'
|
|
|
|
# Template relevant date/datetime formatting
|
|
# See the Note on here: https://docs.djangoproject.com/en/3.2/ref/templates/builtins/#date
|
|
de_formats.DATETIME_FORMAT = "d.m.Y, H:i"
|
|
de_formats.DATE_FORMAT = "d.m.Y"
|
|
|
|
TIME_ZONE = 'Europe/Berlin'
|
|
|
|
USE_I18N = True
|
|
|
|
USE_L10N = True
|
|
|
|
USE_TZ = True
|
|
|
|
LOCALE_PATHS = (
|
|
os.path.join(BASE_DIR, 'locale'),
|
|
)
|
|
|
|
# Static files (CSS, JavaScript, Images)
|
|
# https://docs.djangoproject.com/en/3.1/howto/static-files/
|
|
|
|
STATIC_URL = '/static/'
|
|
STATIC_ROOT = os.path.join(BASE_DIR, "static")
|
|
STATICFILES_DIRS = [
|
|
os.path.join(BASE_DIR, 'konova/static'),
|
|
os.path.join(BASE_DIR, 'templates/map/client'), # NETGIS map client files
|
|
os.path.join(BASE_DIR, 'templates/map/client/libs'), # NETGIS map client files
|
|
]
|
|
|
|
# EMAIL (see https://docs.djangoproject.com/en/dev/topics/email/)
|
|
|
|
# CHANGE_ME !!! ONLY FOR DEVELOPMENT !!!
|
|
if DEBUG:
|
|
EMAIL_BACKEND = 'django.core.mail.backends.filebased.EmailBackend'
|
|
EMAIL_FILE_PATH = '/tmp/app-messages' # change this to a proper location
|
|
|
|
DEFAULT_FROM_EMAIL = env("DEFAULT_FROM_EMAIL") # The default email address for the 'from' element
|
|
SERVER_EMAIL = DEFAULT_FROM_EMAIL # The default email sender address, which is used by Django to send errors via mail
|
|
EMAIL_HOST = env("SMTP_HOST")
|
|
EMAIL_REPLY_TO = env("REPLY_TO_ADDR")
|
|
EMAIL_PORT = env("SMTP_PORT")
|
|
EMAIL_USE_TLS = False
|
|
EMAIL_USE_SSL = False
|