2016-07-15 00:02:56 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
2016-05-26 04:06:17 +02:00
|
|
|
"""
|
2017-04-10 23:18:00 +02:00
|
|
|
Django common settings for cof project.
|
2016-05-26 04:06:17 +02:00
|
|
|
|
2017-04-10 23:18:00 +02:00
|
|
|
Everything which is supposed to be identical between the production server and
|
2017-04-15 12:09:16 +02:00
|
|
|
the local development server should be here.
|
2016-05-26 04:06:17 +02:00
|
|
|
"""
|
|
|
|
|
|
|
|
import os
|
|
|
|
|
2017-04-10 23:18:00 +02:00
|
|
|
# Database credentials
|
|
|
|
try:
|
|
|
|
from .secret import DBNAME, DBUSER, DBPASSWD
|
|
|
|
except ImportError:
|
|
|
|
# On the local development VM, theses credentials are in the environment
|
|
|
|
DBNAME = os.environ["DBNAME"]
|
|
|
|
DBUSER = os.environ["DBUSER"]
|
|
|
|
DBPASSWD = os.environ["DBPASSWD"]
|
|
|
|
except KeyError:
|
|
|
|
raise RuntimeError("Secrets missing")
|
|
|
|
|
2017-04-15 14:41:55 +02:00
|
|
|
|
|
|
|
# Redis settings (for cache and channel layers)
|
|
|
|
try:
|
|
|
|
from .secret import REDIS_USER, REDIS_PASS
|
|
|
|
except ImportError:
|
|
|
|
REDIS_USER = os.environ.get("REDIS_USER", "")
|
|
|
|
REDIS_PASS = os.environ.get("REDIS_PASS", "")
|
|
|
|
|
|
|
|
if REDIS_USER or REDIS_PASS:
|
|
|
|
REDIS_AUTH = REDIS_USER+":"+REDIS_PASS+"@"
|
|
|
|
else:
|
|
|
|
REDIS_AUTH = ''
|
|
|
|
|
|
|
|
REDIS_HOST = os.environ.get("REDIS_HOST", "localhost")
|
|
|
|
REDIS_PORT = os.environ.get("REDIS_PORT", "6379")
|
|
|
|
|
|
|
|
REDIS_BASE_URL = "redis://" + REDIS_AUTH + REDIS_HOST + ":" + REDIS_PORT
|
|
|
|
# To select a specific redis database, do: REDIS_BASE_URL + '/<num_db>'
|
|
|
|
|
|
|
|
|
2017-04-10 23:18:00 +02:00
|
|
|
# Other secrets
|
|
|
|
try:
|
|
|
|
from .secret import (
|
|
|
|
SECRET_KEY, RECAPTCHA_PUBLIC_KEY, RECAPTCHA_PRIVATE_KEY, ADMINS
|
|
|
|
)
|
|
|
|
except ImportError:
|
|
|
|
raise RuntimeError("Secrets missing")
|
|
|
|
|
|
|
|
|
|
|
|
BASE_DIR = os.path.dirname(
|
|
|
|
os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
|
|
)
|
2016-05-26 04:06:17 +02:00
|
|
|
|
|
|
|
|
|
|
|
# Application definition
|
2017-04-10 23:18:00 +02:00
|
|
|
INSTALLED_APPS = [
|
2016-05-26 04:06:17 +02:00
|
|
|
'gestioncof',
|
|
|
|
'django.contrib.auth',
|
|
|
|
'django.contrib.contenttypes',
|
|
|
|
'django.contrib.sessions',
|
|
|
|
'django.contrib.sites',
|
|
|
|
'django.contrib.messages',
|
|
|
|
'django.contrib.staticfiles',
|
|
|
|
'grappelli',
|
|
|
|
'django.contrib.admin',
|
|
|
|
'django.contrib.admindocs',
|
|
|
|
'bda',
|
|
|
|
'autocomplete_light',
|
|
|
|
'captcha',
|
2016-05-26 22:20:04 +02:00
|
|
|
'django_cas_ng',
|
2016-07-11 21:48:11 +02:00
|
|
|
'bootstrapform',
|
2016-08-02 10:40:46 +02:00
|
|
|
'kfet',
|
2016-08-14 20:31:22 +02:00
|
|
|
'channels',
|
2016-09-03 16:29:32 +02:00
|
|
|
'widget_tweaks',
|
2016-12-22 02:00:10 +01:00
|
|
|
'custommail',
|
2017-04-03 20:32:16 +02:00
|
|
|
'djconfig',
|
2017-04-10 23:18:00 +02:00
|
|
|
]
|
2016-05-26 04:06:17 +02:00
|
|
|
|
2017-04-10 23:18:00 +02:00
|
|
|
MIDDLEWARE_CLASSES = [
|
2016-05-26 04:06:17 +02:00
|
|
|
'django.contrib.sessions.middleware.SessionMiddleware',
|
|
|
|
'django.middleware.common.CommonMiddleware',
|
|
|
|
'django.middleware.csrf.CsrfViewMiddleware',
|
|
|
|
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
|
|
|
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
|
2016-08-19 06:20:37 +02:00
|
|
|
'kfet.middleware.KFetAuthenticationMiddleware',
|
2016-05-26 04:06:17 +02:00
|
|
|
'django.contrib.messages.middleware.MessageMiddleware',
|
|
|
|
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
|
|
|
'django.middleware.security.SecurityMiddleware',
|
2017-04-03 20:32:16 +02:00
|
|
|
'djconfig.middleware.DjConfigMiddleware',
|
2017-04-10 23:18:00 +02:00
|
|
|
]
|
2016-05-26 04:06:17 +02:00
|
|
|
|
|
|
|
ROOT_URLCONF = 'cof.urls'
|
|
|
|
|
|
|
|
TEMPLATES = [
|
|
|
|
{
|
|
|
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
|
|
|
'DIRS': [],
|
|
|
|
'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',
|
|
|
|
'django.core.context_processors.i18n',
|
|
|
|
'django.core.context_processors.media',
|
|
|
|
'django.core.context_processors.static',
|
2017-04-03 20:32:16 +02:00
|
|
|
'djconfig.context_processors.config',
|
2016-05-26 04:06:17 +02:00
|
|
|
'gestioncof.shared.context_processor',
|
2016-08-20 23:31:30 +02:00
|
|
|
'kfet.context_processors.auth',
|
2017-04-03 20:32:16 +02:00
|
|
|
'kfet.context_processors.config',
|
2016-05-26 04:06:17 +02:00
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
]
|
|
|
|
|
|
|
|
DATABASES = {
|
|
|
|
'default': {
|
|
|
|
'ENGINE': 'django.db.backends.mysql',
|
2017-04-10 23:18:00 +02:00
|
|
|
'NAME': DBNAME,
|
|
|
|
'USER': DBUSER,
|
|
|
|
'PASSWORD': DBPASSWD,
|
2016-11-13 11:29:28 +01:00
|
|
|
'HOST': os.environ.get('DBHOST', 'localhost'),
|
2016-05-26 04:06:17 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# Internationalization
|
|
|
|
# https://docs.djangoproject.com/en/1.8/topics/i18n/
|
|
|
|
|
|
|
|
LANGUAGE_CODE = 'fr-fr'
|
|
|
|
|
|
|
|
TIME_ZONE = 'Europe/Paris'
|
|
|
|
|
|
|
|
USE_I18N = True
|
|
|
|
|
|
|
|
USE_L10N = True
|
|
|
|
|
|
|
|
USE_TZ = True
|
|
|
|
|
|
|
|
# Various additional settings
|
|
|
|
SITE_ID = 1
|
|
|
|
|
|
|
|
GRAPPELLI_ADMIN_HEADLINE = "GestioCOF"
|
|
|
|
GRAPPELLI_ADMIN_TITLE = "<a href=\"/\">GestioCOF</a>"
|
|
|
|
|
2016-09-27 17:57:53 +02:00
|
|
|
MAIL_DATA = {
|
|
|
|
'petits_cours': {
|
|
|
|
'FROM': "Le COF <cof@ens.fr>",
|
|
|
|
'BCC': "archivescof@gmail.com",
|
|
|
|
'REPLYTO': "cof@ens.fr"},
|
|
|
|
'rappels': {
|
|
|
|
'FROM': 'Le BdA <bda@ens.fr>',
|
|
|
|
'REPLYTO': 'Le BdA <bda@ens.fr>'},
|
|
|
|
'revente': {
|
2016-10-03 01:58:55 +02:00
|
|
|
'FROM': 'BdA-Revente <bda-revente@ens.fr>',
|
|
|
|
'REPLYTO': 'BdA-Revente <bda-revente@ens.fr>'},
|
2016-09-27 17:57:53 +02:00
|
|
|
}
|
2016-07-29 01:50:08 +02:00
|
|
|
|
2016-11-06 01:36:10 +01:00
|
|
|
LOGIN_URL = "cof-login"
|
|
|
|
LOGIN_REDIRECT_URL = "home"
|
2016-05-26 04:06:17 +02:00
|
|
|
|
|
|
|
CAS_SERVER_URL = 'https://cas.eleves.ens.fr/'
|
|
|
|
CAS_IGNORE_REFERER = True
|
2016-11-06 01:36:10 +01:00
|
|
|
CAS_REDIRECT_URL = '/'
|
2016-05-26 04:06:17 +02:00
|
|
|
CAS_EMAIL_FORMAT = "%s@clipper.ens.fr"
|
|
|
|
AUTHENTICATION_BACKENDS = (
|
|
|
|
'django.contrib.auth.backends.ModelBackend',
|
|
|
|
'gestioncof.shared.COFCASBackend',
|
2016-09-29 23:17:42 +02:00
|
|
|
'kfet.backends.GenericTeamBackend',
|
2016-05-26 04:06:17 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
RECAPTCHA_USE_SSL = True
|
2016-05-27 01:04:35 +02:00
|
|
|
|
2017-04-10 21:36:00 +02:00
|
|
|
# Cache settings (use db #1 of redis)
|
|
|
|
|
|
|
|
CACHE_REDIS_URL = REDIS_BASE_URL + "/1"
|
|
|
|
|
|
|
|
CACHES = {
|
|
|
|
'default': {
|
|
|
|
'BACKEND': 'redis_cache.RedisCache',
|
|
|
|
'LOCATION': CACHE_REDIS_URL,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# Channels settings (use db #0 of redis)
|
|
|
|
|
|
|
|
CHANNEL_REDIS_URL = REDIS_BASE_URL + "/0"
|
2016-08-14 20:31:22 +02:00
|
|
|
|
|
|
|
CHANNEL_LAYERS = {
|
|
|
|
"default": {
|
|
|
|
"BACKEND": "asgi_redis.RedisChannelLayer",
|
|
|
|
"CONFIG": {
|
2017-04-10 21:36:00 +02:00
|
|
|
"hosts": [CHANNEL_REDIS_URL],
|
2016-08-14 20:31:22 +02:00
|
|
|
},
|
|
|
|
"ROUTING": "cof.routing.channel_routing",
|
|
|
|
}
|
|
|
|
}
|
2016-07-09 22:31:56 +02:00
|
|
|
|
2016-11-08 10:24:17 +01:00
|
|
|
FORMAT_MODULE_PATH = 'cof.locale'
|