forked from DGNum/gestioCOF
c960d97b67
L'application `petitscours` reste assez fortement couplée à `gestioncof`, et n'est pas (encore ?) faite pour être utilisée séparément. De façon similaire, et afin de minimiser de potentiels problèmes dûs à des migrations, les modèles de l'application `petitscours` utilisent `app_label = "gestioncof"` pour que Django les considère comme faisant partie de l'application `"gestioncof"`. Ils pourront être migrés dans un second temps si cela s'avère nécessaire. Les changements sont nombreux, mais assez simples: il s'agit principalement de déplacer des fichiers et changer des imports. J'ai également profité de l'occasion pour réorganiser les templates afin de les placer dans l'espace de nom "petitscours/". cof/ * settings/common.py: Add `petitscours` app * urls.py: Use `petitscours.urls` petitscours/ * __init__.py: Added. * tests/__init__.py: Added. * tests/utils.py: Added. * urls.py: Added. gestioncof/ * admin.py: * management/commands/loaddevdata.py: * models.py: * signals.py: Typo. * urls.py: Moved petitscours_patterns to petitscours.urls * petits_cours_forms.py: Moved to petitscours/forms.py * petits_cours_models.py: Moved to petitscours/models.py * petits_cours_views.py: Moved to petitscours/views.py * tests/utils.py: * tests/test_petitscours_views.py: Moved to petitscours/tests/test_petitscours_views.py * templates/base_title_petitscours.html: Moved to petitscours/templates/petitscours/base_title.html * templates/demande-petit-cours.html: Moved topetitscours/templates/petitscours/demande.html * templates/gestioncof/details_demande_petit_cours.html: Moved to petitscours/templates/petitscours/demande_detail.html * templates/petits_cours_demandes_list.html: Moved to petitscours/templates/petitscours/demande_list.html * templates/demande-petit-cours-raw.html: Moved to petitscours/templates/petitscours/demande_raw.html * templates/details_demande_petit_cours_infos.html: Moved to petitscours/templates/petitscours/details_demande_infos.html * templates/inscription-petit-cours.html: Moved to petitscours/templates/petitscours/inscription.html * templates/inscription-petit-cours-formset.html: Moved to petitscours/templates/petitscours/inscription_formset.html * templates/gestioncof/traitement_demande_petit_cours.html: Moved to petitscours/templates/petitscours/traitement_demande.html * templates/gestioncof/traitement_demande_petit_cours_autre_niveau.html: Moved to petitscours/templates/petitscours/traitement_demande_autre_niveau.html * templates/gestioncof/traitement_demande_petit_cours_success.html: Moved to petitscours/templates/petitscours/traitement_demande_success.html
253 lines
6.6 KiB
Python
253 lines
6.6 KiB
Python
"""
|
|
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
|
|
import sys
|
|
|
|
try:
|
|
from . import secret
|
|
except ImportError:
|
|
raise ImportError(
|
|
"The secret.py file is missing.\n"
|
|
"For a development environment, simply copy secret_example.py"
|
|
)
|
|
|
|
|
|
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")
|
|
SERVER_EMAIL = import_secret("SERVER_EMAIL")
|
|
EMAIL_HOST = import_secret("EMAIL_HOST")
|
|
|
|
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")
|
|
|
|
KFETOPEN_TOKEN = import_secret("KFETOPEN_TOKEN")
|
|
LDAP_SERVER_URL = import_secret("LDAP_SERVER_URL")
|
|
|
|
|
|
BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
|
|
|
TESTING = sys.argv[1] == "test"
|
|
|
|
|
|
# Application definition
|
|
INSTALLED_APPS = [
|
|
"shared",
|
|
"gestioncof",
|
|
# Must be before 'django.contrib.admin'.
|
|
# https://django-autocomplete-light.readthedocs.io/en/master/install.html
|
|
"dal",
|
|
"dal_select2",
|
|
"django.contrib.auth",
|
|
"django.contrib.contenttypes",
|
|
"django.contrib.sessions",
|
|
"django.contrib.sites",
|
|
"django.contrib.messages",
|
|
"django.contrib.staticfiles",
|
|
"django.contrib.admin",
|
|
"django.contrib.admindocs",
|
|
"bda",
|
|
"petitscours",
|
|
"captcha",
|
|
"django_cas_ng",
|
|
"bootstrapform",
|
|
"kfet",
|
|
"kfet.open",
|
|
"channels",
|
|
"widget_tweaks",
|
|
"custommail",
|
|
"djconfig",
|
|
"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",
|
|
"wagtailmenus",
|
|
"modelcluster",
|
|
"taggit",
|
|
"kfet.auth",
|
|
"kfet.cms",
|
|
"corsheaders",
|
|
]
|
|
|
|
MIDDLEWARE = [
|
|
"corsheaders.middleware.CorsMiddleware",
|
|
"django.contrib.sessions.middleware.SessionMiddleware",
|
|
"django.middleware.common.CommonMiddleware",
|
|
"django.middleware.csrf.CsrfViewMiddleware",
|
|
"django.contrib.auth.middleware.AuthenticationMiddleware",
|
|
"django.contrib.auth.middleware.SessionAuthenticationMiddleware",
|
|
"kfet.auth.middleware.TemporaryAuthMiddleware",
|
|
"django.contrib.messages.middleware.MessageMiddleware",
|
|
"django.middleware.clickjacking.XFrameOptionsMiddleware",
|
|
"django.middleware.security.SecurityMiddleware",
|
|
"djconfig.middleware.DjConfigMiddleware",
|
|
"wagtail.wagtailcore.middleware.SiteMiddleware",
|
|
"wagtail.wagtailredirects.middleware.RedirectMiddleware",
|
|
]
|
|
|
|
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.template.context_processors.i18n",
|
|
"django.template.context_processors.media",
|
|
"django.template.context_processors.static",
|
|
"wagtailmenus.context_processors.wagtailmenus",
|
|
"djconfig.context_processors.config",
|
|
"gestioncof.shared.context_processor",
|
|
"kfet.auth.context_processors.temporary_auth",
|
|
"kfet.context_processors.config",
|
|
]
|
|
},
|
|
}
|
|
]
|
|
|
|
DATABASES = {
|
|
"default": {
|
|
"ENGINE": "django.db.backends.postgresql_psycopg2",
|
|
"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_VERSION = "2"
|
|
CAS_LOGIN_MSG = None
|
|
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.auth.backends.GenericBackend",
|
|
)
|
|
|
|
|
|
# reCAPTCHA settings
|
|
# https://github.com/praekelt/django-recaptcha
|
|
#
|
|
# Default settings authorize reCAPTCHA usage for local developement.
|
|
# Public and private keys are appended in the 'prod' module settings.
|
|
|
|
NOCAPTCHA = True
|
|
RECAPTCHA_USE_SSL = True
|
|
|
|
CORS_ORIGIN_WHITELIST = ("bda.ens.fr", "www.bda.ens.fr" "cof.ens.fr", "www.cof.ens.fr")
|
|
|
|
# Cache settings
|
|
|
|
CACHES = {
|
|
"default": {
|
|
"BACKEND": "redis_cache.RedisCache",
|
|
"LOCATION": "redis://:{passwd}@{host}:{port}/db".format(
|
|
passwd=REDIS_PASSWD, host=REDIS_HOST, port=REDIS_PORT, db=REDIS_DB
|
|
),
|
|
}
|
|
}
|
|
|
|
|
|
# Channels settings
|
|
|
|
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": "cof.routing.routing",
|
|
}
|
|
}
|
|
|
|
FORMAT_MODULE_PATH = "cof.locale"
|
|
|
|
# Wagtail settings
|
|
|
|
WAGTAIL_SITE_NAME = "GestioCOF"
|
|
WAGTAIL_ENABLE_UPDATE_CHECK = False
|
|
TAGGIT_CASE_INSENSITIVE = True
|