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
|
|
|
try:
|
2017-08-08 01:06:03 +02:00
|
|
|
from . import secret
|
2017-04-10 23:18:00 +02:00
|
|
|
except ImportError:
|
2017-08-08 01:06:03 +02:00
|
|
|
raise ImportError(
|
|
|
|
"The secret.py file is missing.\n"
|
|
|
|
"For a development environment, simply copy secret_example.py"
|
|
|
|
)
|
2017-04-10 23:18:00 +02:00
|
|
|
|
2017-04-15 14:41:55 +02:00
|
|
|
|
2017-08-08 01:06:03 +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))
|
|
|
|
|
|
|
|
|
|
|
|
SECRET_KEY = import_secret("SECRET_KEY")
|
|
|
|
ADMINS = import_secret("ADMINS")
|
2017-08-08 01:25:13 +02:00
|
|
|
SERVER_EMAIL = import_secret("SERVER_EMAIL")
|
2017-10-25 22:05:14 +02:00
|
|
|
EMAIL_HOST = import_secret("EMAIL_HOST")
|
2017-08-08 01:06:03 +02:00
|
|
|
|
|
|
|
DBNAME = import_secret("DBNAME")
|
|
|
|
DBUSER = import_secret("DBUSER")
|
|
|
|
DBPASSWD = import_secret("DBPASSWD")
|
|
|
|
|
|
|
|
REDIS_PASSWD = import_secret("REDIS_PASSWD")
|
|
|
|
REDIS_DB = import_secret("REDIS_DB")
|
|
|
|
REDIS_HOST = import_secret("REDIS_HOST")
|
|
|
|
REDIS_PORT = import_secret("REDIS_PORT")
|
|
|
|
|
|
|
|
RECAPTCHA_PUBLIC_KEY = import_secret("RECAPTCHA_PUBLIC_KEY")
|
|
|
|
RECAPTCHA_PRIVATE_KEY = import_secret("RECAPTCHA_PRIVATE_KEY")
|
|
|
|
|
|
|
|
KFETOPEN_TOKEN = import_secret("KFETOPEN_TOKEN")
|
2017-09-20 18:19:15 +02:00
|
|
|
LDAP_SERVER_URL = import_secret("LDAP_SERVER_URL")
|
2017-04-10 23:18:00 +02:00
|
|
|
|
|
|
|
|
|
|
|
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',
|
2017-11-19 18:41:39 +01:00
|
|
|
|
|
|
|
# Must be before 'django.contrib.admin'.
|
|
|
|
# https://django-autocomplete-light.readthedocs.io/en/master/install.html
|
|
|
|
'dal',
|
|
|
|
'dal_select2',
|
|
|
|
|
2016-05-26 04:06:17 +02:00
|
|
|
'django.contrib.auth',
|
|
|
|
'django.contrib.contenttypes',
|
|
|
|
'django.contrib.sessions',
|
|
|
|
'django.contrib.sites',
|
|
|
|
'django.contrib.messages',
|
|
|
|
'django.contrib.staticfiles',
|
|
|
|
'django.contrib.admin',
|
|
|
|
'django.contrib.admindocs',
|
2017-11-19 18:41:39 +01:00
|
|
|
|
2016-05-26 04:06:17 +02:00
|
|
|
'bda',
|
|
|
|
'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',
|
2017-06-21 07:08:28 +02:00
|
|
|
'kfet.open',
|
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-05-30 20:44:30 +02:00
|
|
|
'wagtail.wagtailforms',
|
|
|
|
'wagtail.wagtailredirects',
|
|
|
|
'wagtail.wagtailembeds',
|
|
|
|
'wagtail.wagtailsites',
|
|
|
|
'wagtail.wagtailusers',
|
|
|
|
'wagtail.wagtailsnippets',
|
|
|
|
'wagtail.wagtaildocs',
|
|
|
|
'wagtail.wagtailimages',
|
|
|
|
'wagtail.wagtailsearch',
|
|
|
|
'wagtail.wagtailadmin',
|
|
|
|
'wagtail.wagtailcore',
|
|
|
|
'wagtail.contrib.modeladmin',
|
2018-02-03 22:34:37 +01:00
|
|
|
'wagtail.contrib.wagtailroutablepage',
|
2017-05-30 20:44:30 +02:00
|
|
|
'wagtailmenus',
|
|
|
|
'modelcluster',
|
|
|
|
'taggit',
|
2017-08-07 23:31:27 +02:00
|
|
|
'wagtail_modeltranslation',
|
2017-09-13 01:57:31 +02:00
|
|
|
'kfet.auth',
|
2017-05-30 20:44:30 +02:00
|
|
|
'kfet.cms',
|
2017-08-07 23:31:27 +02:00
|
|
|
'gestioncof.cms',
|
2017-04-10 23:18:00 +02:00
|
|
|
]
|
2016-05-26 04:06:17 +02:00
|
|
|
|
2017-11-19 18:41:39 +01:00
|
|
|
MIDDLEWARE = [
|
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',
|
2017-09-25 17:16:19 +02:00
|
|
|
'kfet.auth.middleware.TemporaryAuthMiddleware',
|
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-05-30 20:44:30 +02:00
|
|
|
'wagtail.wagtailcore.middleware.SiteMiddleware',
|
|
|
|
'wagtail.wagtailredirects.middleware.RedirectMiddleware',
|
2017-08-07 23:31:27 +02:00
|
|
|
'django.middleware.locale.LocaleMiddleware',
|
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': [
|
2017-04-15 12:09:16 +02:00
|
|
|
'django.template.context_processors.debug',
|
2016-05-26 04:06:17 +02:00
|
|
|
'django.template.context_processors.request',
|
|
|
|
'django.contrib.auth.context_processors.auth',
|
|
|
|
'django.contrib.messages.context_processors.messages',
|
2017-11-19 18:41:39 +01:00
|
|
|
'django.template.context_processors.i18n',
|
|
|
|
'django.template.context_processors.media',
|
|
|
|
'django.template.context_processors.static',
|
2017-05-30 20:44:30 +02:00
|
|
|
'wagtailmenus.context_processors.wagtailmenus',
|
2017-04-03 20:32:16 +02:00
|
|
|
'djconfig.context_processors.config',
|
2016-05-26 04:06:17 +02:00
|
|
|
'gestioncof.shared.context_processor',
|
2017-09-25 17:16:19 +02:00
|
|
|
'kfet.auth.context_processors.temporary_auth',
|
2017-04-03 20:32:16 +02:00
|
|
|
'kfet.context_processors.config',
|
2016-05-26 04:06:17 +02:00
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
]
|
|
|
|
|
|
|
|
DATABASES = {
|
|
|
|
'default': {
|
2017-08-09 23:07:49 +02:00
|
|
|
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
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
|
|
|
|
|
2017-08-07 23:31:27 +02:00
|
|
|
LANGUAGES = (
|
|
|
|
('fr', u'Français'),
|
|
|
|
('en', u'English'),
|
|
|
|
)
|
|
|
|
|
2016-05-26 04:06:17 +02:00
|
|
|
# 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/'
|
2017-05-30 20:44:30 +02:00
|
|
|
CAS_VERSION = '3'
|
|
|
|
CAS_LOGIN_MSG = None
|
2016-05-26 04:06:17 +02:00
|
|
|
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"
|
2017-05-30 20:44:30 +02:00
|
|
|
|
2016-05-26 04:06:17 +02:00
|
|
|
AUTHENTICATION_BACKENDS = (
|
|
|
|
'django.contrib.auth.backends.ModelBackend',
|
|
|
|
'gestioncof.shared.COFCASBackend',
|
2017-09-25 17:16:19 +02:00
|
|
|
'kfet.auth.backends.GenericBackend',
|
2016-05-26 04:06:17 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
RECAPTCHA_USE_SSL = True
|
2016-05-27 01:04:35 +02:00
|
|
|
|
2017-04-26 11:28:18 +02:00
|
|
|
# Cache settings
|
2017-04-10 21:36:00 +02:00
|
|
|
|
|
|
|
CACHES = {
|
|
|
|
'default': {
|
|
|
|
'BACKEND': 'redis_cache.RedisCache',
|
2017-04-26 11:28:18 +02:00
|
|
|
'LOCATION': 'redis://:{passwd}@{host}:{port}/db'
|
|
|
|
.format(passwd=REDIS_PASSWD, host=REDIS_HOST,
|
|
|
|
port=REDIS_PORT, db=REDIS_DB),
|
2017-04-10 21:36:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-08-14 20:31:22 +02:00
|
|
|
# Channels settings
|
|
|
|
|
|
|
|
CHANNEL_LAYERS = {
|
|
|
|
"default": {
|
|
|
|
"BACKEND": "asgi_redis.RedisChannelLayer",
|
|
|
|
"CONFIG": {
|
2017-04-24 22:27:01 +02:00
|
|
|
"hosts": [(
|
2017-04-25 21:23:21 +02:00
|
|
|
"redis://:{passwd}@{host}:{port}/{db}"
|
|
|
|
.format(passwd=REDIS_PASSWD, host=REDIS_HOST,
|
|
|
|
port=REDIS_PORT, db=REDIS_DB)
|
2017-04-24 22:27:01 +02:00
|
|
|
)],
|
2016-08-14 20:31:22 +02:00
|
|
|
},
|
2017-06-21 07:08:28 +02:00
|
|
|
"ROUTING": "cof.routing.routing",
|
2016-08-14 20:31:22 +02:00
|
|
|
}
|
|
|
|
}
|
2016-07-09 22:31:56 +02:00
|
|
|
|
2016-11-08 10:24:17 +01:00
|
|
|
FORMAT_MODULE_PATH = 'cof.locale'
|
2017-05-30 20:44:30 +02:00
|
|
|
|
|
|
|
# Wagtail settings
|
|
|
|
|
|
|
|
WAGTAIL_SITE_NAME = 'GestioCOF'
|
|
|
|
WAGTAIL_ENABLE_UPDATE_CHECK = False
|
|
|
|
TAGGIT_CASE_INSENSITIVE = True
|