django-refunds/refunds/settings.py

155 lines
4.2 KiB
Python
Raw Permalink 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
from django.contrib import messages
2016-06-03 17:30:41 +02:00
# 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-08-27 21:13:44 +02:00
# Retrieve environment
2018-04-02 12:48:10 +02:00
DEBUG = os.getenv('DJANGO_ENV', 'prod') == 'dev'
2016-06-03 17:30:41 +02:00
2016-08-27 21:13:44 +02:00
SECRET_KEY = os.getenv('SECRET_KEY', '+)2m1(7!+5-p-iazefib&8i7+a4^pod(èer!éç"fn,uo5)jhem(1-bo#p')
2017-02-25 23:10:47 +01:00
ALLOWED_HOSTS = ['localhost', '.herokuapp.com', '.augendre.info', 'refunds-web']
2016-06-03 17:30:41 +02:00
2018-04-02 12:50:58 +02:00
ADMINS = [('Gabriel', os.getenv('ADMIN_EMAIL')), ]
SERVER_EMAIL = os.getenv('SERVER_EMAIL')
EMAIL_SUBJECT_PREFIX = '[Refunds] '
2016-06-03 17:30:41 +02:00
# Application definition
INSTALLED_APPS = [
'refunding',
2016-06-03 20:02:26 +02:00
'authentication',
2016-06-04 03:44:41 +02:00
'bootstrap3_datetime',
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',
]
2016-08-27 21:14:05 +02:00
MIDDLEWARE = [
2016-06-03 17:30:41 +02:00
'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/
2017-03-28 17:11:49 +02:00
LANGUAGE_CODE = os.getenv('DJANGO_LOCALE', 'fr-fr')
2016-06-03 17:30:41 +02:00
2017-03-28 17:11:49 +02:00
TIME_ZONE = os.getenv('DJANGO_TIMEZONE', 'Europe/Paris')
2016-06-03 17:30:41 +02:00
USE_I18N = True
USE_L10N = True
USE_TZ = True
# 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'
)
2018-01-22 21:25:42 +01:00
# Simplified static file serving.
# https://warehouse.python.org/project/whitenoise/
STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'
2016-06-03 19:03:01 +02:00
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'
MESSAGE_TAGS = {
messages.ERROR: 'danger'
}
2018-04-02 12:50:58 +02:00
EMAIL_BACKEND = 'django_mailgun.MailgunBackend'
MAILGUN_ACCESS_KEY = os.getenv('MAILGUN_ACCESS_KEY', '')
MAILGUN_SERVER_NAME = os.getenv('MAILGUN_SERVER_NAME', '')