poulpe/evenementiel/settings/common.py

148 lines
3.9 KiB
Python
Raw Normal View History

# -*- coding: utf-8 -*-
2016-09-28 20:36:48 +02:00
"""
Django common settings for GestionÉvénementiel
2016-09-28 20:36:48 +02:00
Everything which is supposed to be identical between the production server and
the local development server should be here.
2016-09-28 20:36:48 +02:00
We also load the secrets in this file.
2016-09-28 20:36:48 +02:00
"""
import os
from . import secret
2016-09-28 20:36:48 +02:00
def import_secret(name):
"""
Shorthand for importing a value from the secret module and raising an
informative exception if a secret is missing.
"""
try:
return getattr(secret, name)
except AttributeError:
raise RuntimeError("Secret missing: {}".format(name))
2016-09-28 20:36:48 +02:00
SECRET_KEY = import_secret("SECRET_KEY")
ADMINS = import_secret("ADMINS")
2016-09-28 20:36:48 +02:00
DBNAME = import_secret("DBNAME")
DBUSER = import_secret("DBUSER")
DBPASSWD = import_secret("DBPASSWD")
2016-09-28 20:36:48 +02:00
REDIS_PASSWD = import_secret("REDIS_PASSWD")
REDIS_DB = import_secret("REDIS_DB")
REDIS_HOST = import_secret("REDIS_HOST")
REDIS_PORT = import_secret("REDIS_PORT")
2016-09-28 20:36:48 +02:00
2017-05-17 17:18:13 +02:00
CREATE_USER_KEY = import_secret("CREATE_USER_KEY")
2016-09-28 20:36:48 +02:00
BASE_DIR = os.path.dirname(
os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
)
2016-09-28 20:36:48 +02:00
INSTALLED_APPS = [
2017-07-15 21:22:15 +02:00
'communication.apps.CommunicationConfig',
2016-10-14 13:00:51 +02:00
'equipment.apps.EquipmentConfig',
'event.apps.EventConfig',
'users.apps.UsersConfig',
'shared.apps.SharedConfig',
2016-09-28 20:36:48 +02:00
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'channels',
'bootstrapform',
'widget_tweaks',
2016-09-28 20:36:48 +02:00
]
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 = 'evenementiel.urls'
STATIC_URL = "/static/"
MEDIA_URL = "/media/"
LOGIN_REDIRECT_URL = 'shared:home'
LOGOUT_REDIRECT_URL = 'shared:home'
2017-02-21 16:02:23 +01:00
2016-09-28 20:36:48 +02:00
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
2016-09-28 20:36:48 +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',
'shared.shared.context_processor',
2016-09-28 20:36:48 +02:00
],
},
},
]
DATABASES = {
'default': {
2017-05-16 12:42:53 +02:00
'ENGINE': 'django.db.backends.postgresql',
'NAME': DBNAME,
'USER': DBUSER,
'PASSWORD': DBPASSWD,
2016-09-28 20:36:48 +02:00
'PORT': 5432,
2016-09-29 00:13:16 +02:00
'HOST': 'localhost',
2016-09-28 20:36:48 +02:00
}
}
CHANNEL_LAYERS = {
"default": {
"BACKEND": "asgi_redis.RedisChannelLayer",
"CONFIG": {
"hosts": [(
"redis://:{passwd}@{host}:{port}/{db}"
.format(passwd=REDIS_PASSWD, host=REDIS_HOST,
port=REDIS_PORT, db=REDIS_DB)
)],
},
"ROUTING": "evenementiel.routing.channel_routing",
}
}
2016-09-28 20:36:48 +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'},
2016-09-28 20:36:48 +02:00
]
# Internationalization
# https://docs.djangoproject.com/en/1.8/topics/i18n/
2016-09-28 20:36:48 +02:00
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True