forked from DGNum/gestioCOF
Split settings between COF / BDS / Local
This commit is contained in:
parent
d16bf5e6b0
commit
d464b69b2e
4 changed files with 229 additions and 136 deletions
|
@ -6,14 +6,15 @@ The settings that are not listed here are imported from .common
|
|||
import os
|
||||
|
||||
from .common import * # NOQA
|
||||
from .common import BASE_DIR, INSTALLED_APPS, TESTING, import_secret
|
||||
from .common import BASE_DIR, INSTALLED_APPS
|
||||
|
||||
DEBUG = False
|
||||
# ---
|
||||
# BDS-only Django settings
|
||||
# ---
|
||||
|
||||
ALLOWED_HOSTS = ["cof.ens.fr", "www.cof.ens.fr", "dev.cof.ens.fr"]
|
||||
ALLOWED_HOSTS = ["bds.ens.fr", "www.bds.ens.fr", "dev.cof.ens.fr"]
|
||||
|
||||
if TESTING:
|
||||
INSTALLED_APPS += ["events", "clubs"]
|
||||
INSTALLED_APPS += ["bds", "events", "clubs"]
|
||||
|
||||
STATIC_ROOT = os.path.join(
|
||||
os.path.dirname(os.path.dirname(BASE_DIR)), "public", "gestion", "static"
|
||||
|
@ -24,5 +25,9 @@ MEDIA_ROOT = os.path.join(os.path.dirname(BASE_DIR), "media")
|
|||
MEDIA_URL = "/gestion/media/"
|
||||
|
||||
|
||||
RECAPTCHA_PUBLIC_KEY = import_secret("RECAPTCHA_PUBLIC_KEY")
|
||||
RECAPTCHA_PRIVATE_KEY = import_secret("RECAPTCHA_PRIVATE_KEY")
|
||||
# ---
|
||||
# Auth-related stuff
|
||||
# ---
|
||||
|
||||
LOGIN_URL = "admin:login"
|
||||
LOGIN_REDIRECT_URL = "bds:home"
|
162
cof/settings/cof_prod.py
Normal file
162
cof/settings/cof_prod.py
Normal file
|
@ -0,0 +1,162 @@
|
|||
"""
|
||||
Django development settings for the cof project.
|
||||
The settings that are not listed here are imported from .common
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from .common import * # NOQA
|
||||
from .common import (
|
||||
AUTHENTICATION_BACKENDS,
|
||||
BASE_DIR,
|
||||
INSTALLED_APPS,
|
||||
MIDDLEWARE,
|
||||
TEMPLATES,
|
||||
import_secret,
|
||||
)
|
||||
|
||||
# ---
|
||||
# COF-specific secrets
|
||||
# ---
|
||||
|
||||
RECAPTCHA_PUBLIC_KEY = import_secret("RECAPTCHA_PUBLIC_KEY")
|
||||
RECAPTCHA_PRIVATE_KEY = import_secret("RECAPTCHA_PRIVATE_KEY")
|
||||
KFETOPEN_TOKEN = import_secret("KFETOPEN_TOKEN")
|
||||
|
||||
# ---
|
||||
# COF-only Django settings
|
||||
# ---
|
||||
|
||||
ALLOWED_HOSTS = ["cof.ens.fr", "www.cof.ens.fr", "dev.cof.ens.fr"]
|
||||
|
||||
INSTALLED_APPS = (
|
||||
[
|
||||
"gestioncof",
|
||||
# Must be before django admin
|
||||
# https://github.com/infoportugal/wagtail-modeltranslation/issues/193
|
||||
"wagtail_modeltranslation",
|
||||
"wagtail_modeltranslation.makemigrations",
|
||||
"wagtail_modeltranslation.migrate",
|
||||
"modeltranslation",
|
||||
]
|
||||
+ INSTALLED_APPS
|
||||
+ [
|
||||
"bda",
|
||||
"petitscours",
|
||||
"captcha",
|
||||
"kfet",
|
||||
"kfet.open",
|
||||
"channels",
|
||||
"custommail",
|
||||
"djconfig",
|
||||
"wagtail.contrib.forms",
|
||||
"wagtail.contrib.redirects",
|
||||
"wagtail.embeds",
|
||||
"wagtail.sites",
|
||||
"wagtail.users",
|
||||
"wagtail.snippets",
|
||||
"wagtail.documents",
|
||||
"wagtail.images",
|
||||
"wagtail.search",
|
||||
"wagtail.admin",
|
||||
"wagtail.core",
|
||||
"wagtail.contrib.modeladmin",
|
||||
"wagtail.contrib.routable_page",
|
||||
"wagtailmenus",
|
||||
"modelcluster",
|
||||
"taggit",
|
||||
"kfet.auth",
|
||||
"kfet.cms",
|
||||
"gestioncof.cms",
|
||||
"django_js_reverse",
|
||||
]
|
||||
)
|
||||
|
||||
MIDDLEWARE = (
|
||||
["corsheaders.middleware.CorsMiddleware"]
|
||||
+ MIDDLEWARE
|
||||
+ [
|
||||
"djconfig.middleware.DjConfigMiddleware",
|
||||
"wagtail.core.middleware.SiteMiddleware",
|
||||
"wagtail.contrib.redirects.middleware.RedirectMiddleware",
|
||||
]
|
||||
)
|
||||
|
||||
TEMPLATES[0]["OPTIONS"]["context_processors"] += [
|
||||
"wagtailmenus.context_processors.wagtailmenus",
|
||||
"djconfig.context_processors.config",
|
||||
"gestioncof.shared.context_processor",
|
||||
"kfet.auth.context_processors.temporary_auth",
|
||||
"kfet.context_processors.config",
|
||||
]
|
||||
|
||||
STATIC_ROOT = os.path.join(
|
||||
os.path.dirname(os.path.dirname(BASE_DIR)), "public", "gestion", "static"
|
||||
)
|
||||
|
||||
STATIC_URL = "/gestion/static/"
|
||||
MEDIA_ROOT = os.path.join(os.path.dirname(BASE_DIR), "media")
|
||||
MEDIA_URL = "/gestion/media/"
|
||||
|
||||
CORS_ORIGIN_WHITELIST = ("bda.ens.fr", "www.bda.ens.fr" "cof.ens.fr", "www.cof.ens.fr")
|
||||
|
||||
|
||||
# ---
|
||||
# Auth-related stuff
|
||||
# ---
|
||||
|
||||
AUTHENTICATION_BACKENDS += [
|
||||
"gestioncof.shared.COFCASBackend",
|
||||
"kfet.auth.backends.GenericBackend",
|
||||
]
|
||||
|
||||
LOGIN_URL = "cof-login"
|
||||
LOGIN_REDIRECT_URL = "home"
|
||||
|
||||
|
||||
# ---
|
||||
# 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
|
||||
|
||||
|
||||
# ---
|
||||
# Wagtail settings
|
||||
# ---
|
||||
|
||||
WAGTAIL_SITE_NAME = "GestioCOF"
|
||||
WAGTAIL_ENABLE_UPDATE_CHECK = False
|
||||
TAGGIT_CASE_INSENSITIVE = True
|
||||
|
||||
|
||||
# ---
|
||||
# Django-js-reverse settings
|
||||
# ---
|
||||
|
||||
JS_REVERSE_JS_VAR_NAME = "django_urls"
|
||||
# Quand on aura namespace les urls...
|
||||
# JS_REVERSE_INCLUDE_ONLY_NAMESPACES = ['k-fet']
|
||||
|
||||
|
||||
# ---
|
||||
# Mail config
|
||||
# ---
|
||||
|
||||
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>",
|
||||
},
|
||||
}
|
|
@ -8,6 +8,10 @@ the local development server should be here.
|
|||
import os
|
||||
import sys
|
||||
|
||||
# ---
|
||||
# Secrets
|
||||
# ---
|
||||
|
||||
try:
|
||||
from . import secret
|
||||
except ImportError:
|
||||
|
@ -42,19 +46,19 @@ 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")
|
||||
|
||||
|
||||
# ---
|
||||
# Default Django settings
|
||||
# ---
|
||||
|
||||
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__))))
|
||||
|
||||
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",
|
||||
|
@ -64,51 +68,15 @@ INSTALLED_APPS = [
|
|||
"django.contrib.sessions",
|
||||
"django.contrib.sites",
|
||||
"django.contrib.messages",
|
||||
"cof.apps.IgnoreSrcStaticFilesConfig",
|
||||
# Must be before django admin
|
||||
# https://github.com/infoportugal/wagtail-modeltranslation/issues/193
|
||||
"wagtail_modeltranslation",
|
||||
"wagtail_modeltranslation.makemigrations",
|
||||
"wagtail_modeltranslation.migrate",
|
||||
"modeltranslation",
|
||||
"django.contrib.admin",
|
||||
"django.contrib.admindocs",
|
||||
"bda",
|
||||
"petitscours",
|
||||
"captcha",
|
||||
"cof.apps.IgnoreSrcStaticFilesConfig",
|
||||
"django_cas_ng",
|
||||
"bootstrapform",
|
||||
"kfet",
|
||||
"kfet.open",
|
||||
"channels",
|
||||
"widget_tweaks",
|
||||
"custommail",
|
||||
"djconfig",
|
||||
"wagtail.contrib.forms",
|
||||
"wagtail.contrib.redirects",
|
||||
"wagtail.embeds",
|
||||
"wagtail.sites",
|
||||
"wagtail.users",
|
||||
"wagtail.snippets",
|
||||
"wagtail.documents",
|
||||
"wagtail.images",
|
||||
"wagtail.search",
|
||||
"wagtail.admin",
|
||||
"wagtail.core",
|
||||
"wagtail.contrib.modeladmin",
|
||||
"wagtail.contrib.routable_page",
|
||||
"wagtailmenus",
|
||||
"modelcluster",
|
||||
"taggit",
|
||||
"kfet.auth",
|
||||
"kfet.cms",
|
||||
"gestioncof.cms",
|
||||
"django_js_reverse",
|
||||
]
|
||||
|
||||
|
||||
MIDDLEWARE = [
|
||||
"corsheaders.middleware.CorsMiddleware",
|
||||
"django.contrib.sessions.middleware.SessionMiddleware",
|
||||
"django.middleware.common.CommonMiddleware",
|
||||
"django.middleware.csrf.CsrfViewMiddleware",
|
||||
|
@ -116,9 +84,6 @@ MIDDLEWARE = [
|
|||
"django.contrib.messages.middleware.MessageMiddleware",
|
||||
"django.middleware.clickjacking.XFrameOptionsMiddleware",
|
||||
"django.middleware.security.SecurityMiddleware",
|
||||
"djconfig.middleware.DjConfigMiddleware",
|
||||
"wagtail.core.middleware.SiteMiddleware",
|
||||
"wagtail.contrib.redirects.middleware.RedirectMiddleware",
|
||||
"django.middleware.locale.LocaleMiddleware",
|
||||
]
|
||||
|
||||
|
@ -127,7 +92,6 @@ ROOT_URLCONF = "cof.urls"
|
|||
TEMPLATES = [
|
||||
{
|
||||
"BACKEND": "django.template.backends.django.DjangoTemplates",
|
||||
"DIRS": [],
|
||||
"APP_DIRS": True,
|
||||
"OPTIONS": {
|
||||
"context_processors": [
|
||||
|
@ -138,11 +102,6 @@ TEMPLATES = [
|
|||
"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",
|
||||
]
|
||||
},
|
||||
}
|
||||
|
@ -158,43 +117,28 @@ DATABASES = {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
# 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
|
||||
|
||||
LANGUAGES = (("fr", "Français"), ("en", "English"))
|
||||
|
||||
# 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>",
|
||||
},
|
||||
}
|
||||
# ---
|
||||
# Internationalization
|
||||
# https://docs.djangoproject.com/en/1.8/topics/i18n/
|
||||
# ---
|
||||
|
||||
LOGIN_URL = "cof-login"
|
||||
LOGIN_REDIRECT_URL = "home"
|
||||
LANGUAGE_CODE = "fr-fr"
|
||||
TIME_ZONE = "Europe/Paris"
|
||||
USE_I18N = True
|
||||
USE_L10N = True
|
||||
USE_TZ = True
|
||||
LANGUAGES = (("fr", "Français"), ("en", "English"))
|
||||
FORMAT_MODULE_PATH = "cof.locale"
|
||||
|
||||
|
||||
# ---
|
||||
# Auth-related stuff
|
||||
# ---
|
||||
|
||||
AUTHENTICATION_BACKENDS = ["django.contrib.auth.backends.ModelBackend"]
|
||||
|
||||
CAS_SERVER_URL = "https://cas.eleves.ens.fr/"
|
||||
CAS_VERSION = "2"
|
||||
|
@ -203,37 +147,23 @@ 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(
|
||||
"LOCATION": "redis://:{passwd}@{host}:{port}/{db}".format(
|
||||
passwd=REDIS_PASSWD, host=REDIS_HOST, port=REDIS_PORT, db=REDIS_DB
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# ---
|
||||
# Channels settings
|
||||
# ---
|
||||
|
||||
CHANNEL_LAYERS = {
|
||||
"default": {
|
||||
|
@ -253,16 +183,3 @@ CHANNEL_LAYERS = {
|
|||
"ROUTING": "cof.routing.routing",
|
||||
}
|
||||
}
|
||||
|
||||
FORMAT_MODULE_PATH = "cof.locale"
|
||||
|
||||
# Wagtail settings
|
||||
|
||||
WAGTAIL_SITE_NAME = "GestioCOF"
|
||||
WAGTAIL_ENABLE_UPDATE_CHECK = False
|
||||
TAGGIT_CASE_INSENSITIVE = True
|
||||
|
||||
# Django-js-reverse settings
|
||||
JS_REVERSE_JS_VAR_NAME = "django_urls"
|
||||
# Quand on aura namespace les urls...
|
||||
# JS_REVERSE_INCLUDE_ONLY_NAMESPACES = ['k-fet']
|
||||
|
|
|
@ -1,26 +1,35 @@
|
|||
"""
|
||||
Django local development settings for the cof project.
|
||||
The settings that are not listed here are imported from .common
|
||||
"""
|
||||
"""Django local development settings."""
|
||||
|
||||
import os
|
||||
|
||||
from .common import * # NOQA
|
||||
from .common import BASE_DIR, INSTALLED_APPS, MIDDLEWARE, TESTING
|
||||
from . import bds_prod
|
||||
from .cof_prod import * # NOQA
|
||||
from .cof_prod import BASE_DIR, INSTALLED_APPS, MIDDLEWARE, TESTING
|
||||
|
||||
EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
|
||||
# ---
|
||||
# Merge COF and BDS configs
|
||||
# ---
|
||||
|
||||
for app in bds_prod.INSTALLED_APPS:
|
||||
if app not in INSTALLED_APPS:
|
||||
INSTALLED_APPS.append(app)
|
||||
|
||||
|
||||
# ---
|
||||
# Tweaks for debug/local development
|
||||
# ---
|
||||
|
||||
ALLOWED_HOSTS = None
|
||||
|
||||
DEBUG = True
|
||||
EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
|
||||
|
||||
if TESTING:
|
||||
PASSWORD_HASHERS = ["django.contrib.auth.hashers.MD5PasswordHasher"]
|
||||
|
||||
# As long as these apps are not ready for production, they are only available
|
||||
# in development mode
|
||||
INSTALLED_APPS += ["events", "bds", "clubs"]
|
||||
|
||||
STATIC_URL = "/static/"
|
||||
MEDIA_URL = os.path.join(BASE_DIR, "media")
|
||||
MEDIA_URL = "/media/"
|
||||
MEDIA_ROOT = os.path.join(BASE_DIR, "media")
|
||||
|
||||
DATABASES = {
|
||||
"default": {
|
||||
|
|
Loading…
Reference in a new issue