171 lines
4.5 KiB
Python
171 lines
4.5 KiB
Python
"""
|
|
Django settings for refunds project.
|
|
|
|
Generated by 'django-admin startproject' using Django 1.9.4.
|
|
|
|
For more information on this file, see
|
|
https://docs.djangoproject.com/en/1.9/topics/settings/
|
|
|
|
For the full list of settings and their values, see
|
|
https://docs.djangoproject.com/en/1.9/ref/settings/
|
|
"""
|
|
|
|
import ast
|
|
|
|
import dj_database_url
|
|
import os
|
|
from django.contrib import messages
|
|
|
|
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
|
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
|
|
# Retrieve environment
|
|
ENV = os.getenv('DJANGO_ENV', 'prod')
|
|
debug_env = os.getenv('DEBUG', None)
|
|
|
|
# Define production
|
|
PROD = ENV in ['prod', 'production']
|
|
|
|
# By default, if we're in prod, we don't want debug
|
|
DEBUG = not PROD
|
|
|
|
# But we can override this.
|
|
if debug_env is not None:
|
|
DEBUG = ast.literal_eval(debug_env)
|
|
|
|
# SSL will be required if in prod, unless the SSL is set to False.
|
|
ssl_required = PROD and ast.literal_eval(os.getenv('SSL', 'True'))
|
|
|
|
SECURE_BROWSER_XSS_FILTER = ssl_required
|
|
SECURE_CONTENT_TYPE_NOSNIFF = ssl_required
|
|
SESSION_COOKIE_SECURE = ssl_required
|
|
CSRF_COOKIE_SECURE = ssl_required
|
|
CSRF_COOKIE_HTTPONLY = PROD
|
|
USE_X_FORWARDED_HOST = PROD
|
|
|
|
SECRET_KEY = os.getenv('SECRET_KEY', '+)2m1(7!+5-p-iazefib&8i7+a4^pod(èer!éç"fn,uo5)jhem(1-bo#p')
|
|
|
|
ALLOWED_HOSTS = ['localhost', '.herokuapp.com', '.augendre.info', 'refunds-web']
|
|
|
|
X_FRAME_OPTIONS = 'DENY'
|
|
|
|
# Application definition
|
|
|
|
INSTALLED_APPS = [
|
|
'refunding',
|
|
'authentication',
|
|
'bootstrap3_datetime',
|
|
'crispy_forms',
|
|
'django.contrib.admin',
|
|
'django.contrib.auth',
|
|
'django.contrib.contenttypes',
|
|
'django.contrib.sessions',
|
|
'django.contrib.messages',
|
|
'django.contrib.staticfiles',
|
|
]
|
|
|
|
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.auth.middleware.SessionAuthenticationMiddleware',
|
|
'django.contrib.messages.middleware.MessageMiddleware',
|
|
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
|
]
|
|
|
|
ROOT_URLCONF = 'refunds.urls'
|
|
|
|
TEMPLATES = [
|
|
{
|
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
|
'DIRS': ['templates', 'refunds/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 = 'refunds.wsgi.application'
|
|
|
|
# Database
|
|
# https://docs.djangoproject.com/en/1.9/ref/settings/#databases
|
|
|
|
DATABASES = {
|
|
'default': {
|
|
'ENGINE': 'django.db.backends.sqlite3',
|
|
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
|
|
}
|
|
}
|
|
|
|
db_from_env = dj_database_url.config(conn_max_age=500)
|
|
DATABASES['default'].update(db_from_env)
|
|
|
|
# Password validation
|
|
# https://docs.djangoproject.com/en/1.9/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/1.9/topics/i18n/
|
|
|
|
LANGUAGE_CODE = os.getenv('DJANGO_LOCALE', 'fr-fr')
|
|
|
|
TIME_ZONE = os.getenv('DJANGO_TIMEZONE', 'Europe/Paris')
|
|
|
|
USE_I18N = True
|
|
|
|
USE_L10N = True
|
|
|
|
USE_TZ = True
|
|
|
|
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
|
|
|
|
# Static files (CSS, JavaScript, Images)
|
|
# https://docs.djangoproject.com/en/1.9/howto/static-files/
|
|
|
|
PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
|
|
|
|
STATIC_ROOT = os.path.join(PROJECT_ROOT, 'staticfiles')
|
|
STATIC_URL = '/static/'
|
|
|
|
# Extra places for collectstatic to find static files.
|
|
STATICFILES_DIRS = (
|
|
os.path.join(PROJECT_ROOT, 'static'),
|
|
'static'
|
|
)
|
|
|
|
# Simplified static file serving.
|
|
# https://warehouse.python.org/project/whitenoise/
|
|
|
|
STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'
|
|
|
|
LOGIN_URL = 'auth_login'
|
|
LOGOUT_URL = 'auth_logout'
|
|
LOGIN_REDIRECT_URL = 'home'
|
|
|
|
CRISPY_TEMPLATE_PACK = 'bootstrap3'
|
|
|
|
MESSAGE_TAGS = {
|
|
messages.ERROR: 'danger'
|
|
}
|