forked from DGNum/gestioCOF
194 lines
4.9 KiB
Python
194 lines
4.9 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""
|
|
Django common settings for cof project.
|
|
|
|
Everything which is supposed to be identical between the production server and
|
|
the local development server should be here.
|
|
"""
|
|
|
|
import os
|
|
|
|
# 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")
|
|
|
|
# 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__)))
|
|
)
|
|
|
|
|
|
# Application definition
|
|
INSTALLED_APPS = [
|
|
'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',
|
|
'django_cas_ng',
|
|
'bootstrapform',
|
|
'kfet',
|
|
'channels',
|
|
'widget_tweaks',
|
|
'custommail',
|
|
'djconfig',
|
|
]
|
|
|
|
MIDDLEWARE_CLASSES = [
|
|
'django.contrib.sessions.middleware.SessionMiddleware',
|
|
'django.middleware.common.CommonMiddleware',
|
|
'django.middleware.csrf.CsrfViewMiddleware',
|
|
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
|
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
|
|
'kfet.middleware.KFetAuthenticationMiddleware',
|
|
'django.contrib.messages.middleware.MessageMiddleware',
|
|
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
|
'django.middleware.security.SecurityMiddleware',
|
|
'djconfig.middleware.DjConfigMiddleware',
|
|
]
|
|
|
|
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',
|
|
'djconfig.context_processors.config',
|
|
'gestioncof.shared.context_processor',
|
|
'kfet.context_processors.auth',
|
|
'kfet.context_processors.config',
|
|
],
|
|
},
|
|
},
|
|
]
|
|
|
|
DATABASES = {
|
|
'default': {
|
|
'ENGINE': 'django.db.backends.mysql',
|
|
'NAME': DBNAME,
|
|
'USER': DBUSER,
|
|
'PASSWORD': DBPASSWD,
|
|
'HOST': os.environ.get('DBHOST', 'localhost'),
|
|
}
|
|
}
|
|
|
|
|
|
# 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>"
|
|
|
|
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': {
|
|
'FROM': 'BdA-Revente <bda-revente@ens.fr>',
|
|
'REPLYTO': 'BdA-Revente <bda-revente@ens.fr>'},
|
|
}
|
|
|
|
LOGIN_URL = "cof-login"
|
|
LOGIN_REDIRECT_URL = "home"
|
|
|
|
CAS_SERVER_URL = 'https://cas.eleves.ens.fr/'
|
|
CAS_IGNORE_REFERER = True
|
|
CAS_REDIRECT_URL = '/'
|
|
CAS_EMAIL_FORMAT = "%s@clipper.ens.fr"
|
|
AUTHENTICATION_BACKENDS = (
|
|
'django.contrib.auth.backends.ModelBackend',
|
|
'gestioncof.shared.COFCASBackend',
|
|
'kfet.backends.GenericTeamBackend',
|
|
)
|
|
|
|
RECAPTCHA_USE_SSL = True
|
|
|
|
|
|
# Redis settings (for cache and channel layers)
|
|
|
|
REDIS_HOST = os.environ.get("REDIS_HOST", "localhost")
|
|
REDIS_USER = os.environ.get("REDIS_USER", "")
|
|
REDIS_PASS = os.environ.get("REDIS_PASS", "")
|
|
REDIS_PORT = os.environ.get("REDIS_PORT", "6379")
|
|
|
|
REDIS_AUTH = REDIS_USER+":"+REDIS_PASS+"@" if REDIS_USER or REDIS_PASS else ''
|
|
REDIS_BASE_URL = "redis://" + REDIS_AUTH + REDIS_HOST + ":" + REDIS_PORT
|
|
|
|
|
|
# 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"
|
|
|
|
CHANNEL_LAYERS = {
|
|
"default": {
|
|
"BACKEND": "asgi_redis.RedisChannelLayer",
|
|
"CONFIG": {
|
|
"hosts": [CHANNEL_REDIS_URL],
|
|
},
|
|
"ROUTING": "cof.routing.channel_routing",
|
|
}
|
|
}
|
|
|
|
FORMAT_MODULE_PATH = 'cof.locale'
|