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
|
2018-01-15 05:26:33 +01:00
|
|
|
import sys
|
2016-05-26 04:06:17 +02:00
|
|
|
|
2020-05-09 15:48:51 +02:00
|
|
|
# ---
|
|
|
|
# Secrets
|
|
|
|
# ---
|
|
|
|
|
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")
|
|
|
|
|
2017-09-20 18:19:15 +02:00
|
|
|
LDAP_SERVER_URL = import_secret("LDAP_SERVER_URL")
|
2017-04-10 23:18:00 +02:00
|
|
|
|
|
|
|
|
2020-05-09 15:48:51 +02:00
|
|
|
# ---
|
|
|
|
# Default Django settings
|
|
|
|
# ---
|
2016-05-26 04:06:17 +02:00
|
|
|
|
2020-05-09 15:48:51 +02:00
|
|
|
DEBUG = False # False by default feels safer
|
|
|
|
TESTING = len(sys.argv) > 1 and sys.argv[1] == "test"
|
|
|
|
BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
2016-05-26 04:06:17 +02:00
|
|
|
|
2017-04-10 23:18:00 +02:00
|
|
|
INSTALLED_APPS = [
|
2018-10-06 12:35:49 +02:00
|
|
|
"shared",
|
2017-11-19 18:41:39 +01:00
|
|
|
# Must be before 'django.contrib.admin'.
|
|
|
|
# https://django-autocomplete-light.readthedocs.io/en/master/install.html
|
2019-01-06 00:25:41 +01:00
|
|
|
"dal",
|
|
|
|
"dal_select2",
|
|
|
|
"django.contrib.auth",
|
|
|
|
"django.contrib.contenttypes",
|
|
|
|
"django.contrib.sessions",
|
|
|
|
"django.contrib.sites",
|
|
|
|
"django.contrib.messages",
|
|
|
|
"django.contrib.admin",
|
|
|
|
"django.contrib.admindocs",
|
2020-05-09 15:48:51 +02:00
|
|
|
"cof.apps.IgnoreSrcStaticFilesConfig",
|
2019-01-06 00:25:41 +01:00
|
|
|
"django_cas_ng",
|
|
|
|
"bootstrapform",
|
|
|
|
"widget_tweaks",
|
2020-09-15 00:44:42 +02:00
|
|
|
"authens",
|
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 = [
|
2019-01-06 00:25:41 +01:00
|
|
|
"django.contrib.sessions.middleware.SessionMiddleware",
|
|
|
|
"django.middleware.common.CommonMiddleware",
|
|
|
|
"django.middleware.csrf.CsrfViewMiddleware",
|
|
|
|
"django.contrib.auth.middleware.AuthenticationMiddleware",
|
|
|
|
"django.contrib.messages.middleware.MessageMiddleware",
|
|
|
|
"django.middleware.clickjacking.XFrameOptionsMiddleware",
|
|
|
|
"django.middleware.security.SecurityMiddleware",
|
|
|
|
"django.middleware.locale.LocaleMiddleware",
|
2017-04-10 23:18:00 +02:00
|
|
|
]
|
2016-05-26 04:06:17 +02:00
|
|
|
|
2018-10-06 12:35:49 +02:00
|
|
|
ROOT_URLCONF = "cof.urls"
|
2016-05-26 04:06:17 +02:00
|
|
|
|
|
|
|
TEMPLATES = [
|
|
|
|
{
|
2018-10-06 12:35:49 +02:00
|
|
|
"BACKEND": "django.template.backends.django.DjangoTemplates",
|
|
|
|
"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.template.context_processors.i18n",
|
|
|
|
"django.template.context_processors.media",
|
|
|
|
"django.template.context_processors.static",
|
|
|
|
]
|
2016-05-26 04:06:17 +02:00
|
|
|
},
|
2018-10-06 12:35:49 +02:00
|
|
|
}
|
2016-05-26 04:06:17 +02:00
|
|
|
]
|
|
|
|
|
|
|
|
DATABASES = {
|
2018-10-06 12:35:49 +02:00
|
|
|
"default": {
|
|
|
|
"ENGINE": "django.db.backends.postgresql_psycopg2",
|
|
|
|
"NAME": DBNAME,
|
|
|
|
"USER": DBUSER,
|
|
|
|
"PASSWORD": DBPASSWD,
|
|
|
|
"HOST": os.environ.get("DBHOST", "localhost"),
|
2016-05-26 04:06:17 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-09 15:48:51 +02:00
|
|
|
SITE_ID = 1
|
|
|
|
|
2016-05-26 04:06:17 +02:00
|
|
|
|
2020-05-09 15:48:51 +02:00
|
|
|
# ---
|
2016-05-26 04:06:17 +02:00
|
|
|
# Internationalization
|
|
|
|
# https://docs.djangoproject.com/en/1.8/topics/i18n/
|
2020-05-09 15:48:51 +02:00
|
|
|
# ---
|
2016-05-26 04:06:17 +02:00
|
|
|
|
2018-10-06 12:35:49 +02:00
|
|
|
LANGUAGE_CODE = "fr-fr"
|
|
|
|
TIME_ZONE = "Europe/Paris"
|
2016-05-26 04:06:17 +02:00
|
|
|
USE_I18N = True
|
|
|
|
USE_L10N = True
|
|
|
|
USE_TZ = True
|
2019-01-06 00:25:41 +01:00
|
|
|
LANGUAGES = (("fr", "Français"), ("en", "English"))
|
2020-05-09 15:48:51 +02:00
|
|
|
FORMAT_MODULE_PATH = "cof.locale"
|
2017-08-07 23:31:27 +02:00
|
|
|
|
2016-05-26 04:06:17 +02:00
|
|
|
|
2020-05-09 15:48:51 +02:00
|
|
|
# ---
|
|
|
|
# Auth-related stuff
|
|
|
|
# ---
|
2016-07-29 01:50:08 +02:00
|
|
|
|
2020-05-09 15:48:51 +02:00
|
|
|
AUTHENTICATION_BACKENDS = ["django.contrib.auth.backends.ModelBackend"]
|
2016-05-26 04:06:17 +02:00
|
|
|
|
2018-10-06 12:35:49 +02:00
|
|
|
CAS_SERVER_URL = "https://cas.eleves.ens.fr/"
|
2018-11-12 00:54:44 +01:00
|
|
|
CAS_VERSION = "2"
|
2017-05-30 20:44:30 +02:00
|
|
|
CAS_LOGIN_MSG = None
|
2016-05-26 04:06:17 +02:00
|
|
|
CAS_IGNORE_REFERER = True
|
2018-10-06 12:35:49 +02:00
|
|
|
CAS_REDIRECT_URL = "/"
|
2016-05-26 04:06:17 +02:00
|
|
|
CAS_EMAIL_FORMAT = "%s@clipper.ens.fr"
|
2020-09-15 00:44:42 +02:00
|
|
|
|
|
|
|
AUTHENS_USE_OLDCAS = False
|