django-refunds/refunds/settings.py

163 lines
4.4 KiB
Python
Raw Normal View History

2016-06-03 17:30:41 +02:00
"""
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/
"""
2016-06-03 19:03:01 +02:00
import ast
import dj_database_url
2016-06-03 17:30:41 +02:00
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
2016-06-03 19:03:01 +02:00
ENV = os.getenv('DJANGO_ENV', 'prod')
PROD = ENV in ['prod', 'production']
DEBUG = not PROD
debug_env = os.getenv('DEBUG', None)
if debug_env is not None:
DEBUG = ast.literal_eval(debug_env)
ssl_required = PROD and ast.literal_eval(os.getenv('SSL', 'True'))
2016-06-03 17:30:41 +02:00
2016-06-03 19:03:01 +02:00
SECRET_KEY = os.getenv('SECRET_KEY', '+)2m1(7!+5-p-iazefib&8i7+a4^pod(èer!éç"fn,uo5)jhem(1-bo#p')
2016-06-03 17:30:41 +02:00
2016-06-03 19:03:01 +02:00
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
2016-06-03 17:30:41 +02:00
2016-06-03 19:03:01 +02:00
# We don't want to redirect but thrown an error if no SSL in prod.
# See api.middleware.RejectHTTPMiddleware
SECURE_SSL_REDIRECT = ssl_required
2016-06-03 17:30:41 +02:00
2016-06-03 19:03:01 +02:00
ALLOWED_HOSTS = ['localhost', '.herokuapp.com', '.augendre.info']
2016-06-03 17:30:41 +02:00
2016-06-03 19:03:01 +02:00
X_FRAME_OPTIONS = 'DENY'
2016-06-03 17:30:41 +02:00
# Application definition
INSTALLED_APPS = [
'refunding',
2016-06-03 20:02:26 +02:00
'authentication',
2016-06-03 19:03:01 +02:00
'crispy_forms',
2016-06-03 17:30:41 +02:00
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
MIDDLEWARE_CLASSES = [
'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',
2016-06-03 19:03:01 +02:00
'DIRS': ['templates', 'refunds/templates'],
2016-06-03 17:30:41 +02:00
'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'),
}
}
2016-06-03 19:03:01 +02:00
db_from_env = dj_database_url.config(conn_max_age=500)
DATABASES['default'].update(db_from_env)
2016-06-03 17:30:41 +02:00
# 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/
2016-06-03 19:03:01 +02:00
LANGUAGE_CODE = os.getenv('DJANGO_LOCALE', 'en-us')
2016-06-03 17:30:41 +02:00
2016-06-03 19:03:01 +02:00
TIME_ZONE = os.getenv('DJANGO_TIMEZONE', 'UTC')
2016-06-03 17:30:41 +02:00
USE_I18N = True
USE_L10N = True
USE_TZ = True
2016-06-03 19:03:01 +02:00
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
2016-06-03 17:30:41 +02:00
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.9/howto/static-files/
2016-06-03 19:03:01 +02:00
PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
STATIC_ROOT = os.path.join(PROJECT_ROOT, 'staticfiles')
2016-06-03 17:30:41 +02:00
STATIC_URL = '/static/'
2016-06-03 19:03:01 +02:00
# 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'
2016-06-03 20:02:26 +02:00
LOGIN_URL = 'auth_login'
LOGOUT_URL = 'auth_logout'
LOGIN_REDIRECT_URL = 'home'
2016-06-03 19:03:01 +02:00
CRISPY_TEMPLATE_PACK = 'bootstrap3'