forked from DGNum/gestioCOF
Merge branch 'kerl/bds_settings' into 'master'
Séparation des settings cof / bds See merge request klub-dev-ens/gestioCOF!420
This commit is contained in:
commit
28370c8e67
10 changed files with 422 additions and 310 deletions
|
@ -2,7 +2,6 @@ image: "python:3.7"
|
||||||
|
|
||||||
variables:
|
variables:
|
||||||
# GestioCOF settings
|
# GestioCOF settings
|
||||||
DJANGO_SETTINGS_MODULE: "cof.settings.prod"
|
|
||||||
DBHOST: "postgres"
|
DBHOST: "postgres"
|
||||||
REDIS_HOST: "redis"
|
REDIS_HOST: "redis"
|
||||||
REDIS_PASSWD: "dummy"
|
REDIS_PASSWD: "dummy"
|
||||||
|
@ -18,8 +17,7 @@ variables:
|
||||||
# psql password authentication
|
# psql password authentication
|
||||||
PGPASSWORD: $POSTGRES_PASSWORD
|
PGPASSWORD: $POSTGRES_PASSWORD
|
||||||
|
|
||||||
test:
|
.test_template:
|
||||||
stage: test
|
|
||||||
before_script:
|
before_script:
|
||||||
- mkdir -p vendor/{pip,apt}
|
- mkdir -p vendor/{pip,apt}
|
||||||
- apt-get update -q && apt-get -o dir::cache::archives="vendor/apt" install -yqq postgresql-client libldap2-dev libsasl2-dev
|
- apt-get update -q && apt-get -o dir::cache::archives="vendor/apt" install -yqq postgresql-client libldap2-dev libsasl2-dev
|
||||||
|
@ -29,8 +27,6 @@ test:
|
||||||
- psql --username=$POSTGRES_USER --host=$DBHOST -c "DROP DATABASE IF EXISTS test_$POSTGRES_DB"
|
- psql --username=$POSTGRES_USER --host=$DBHOST -c "DROP DATABASE IF EXISTS test_$POSTGRES_DB"
|
||||||
- pip install --upgrade -r requirements-prod.txt coverage tblib
|
- pip install --upgrade -r requirements-prod.txt coverage tblib
|
||||||
- python --version
|
- python --version
|
||||||
script:
|
|
||||||
- coverage run manage.py test --parallel
|
|
||||||
after_script:
|
after_script:
|
||||||
- coverage report
|
- coverage report
|
||||||
services:
|
services:
|
||||||
|
@ -44,6 +40,22 @@ test:
|
||||||
# Keep this disabled for now, as it may kill GitLab...
|
# Keep this disabled for now, as it may kill GitLab...
|
||||||
# coverage: '/TOTAL.*\s(\d+\.\d+)\%$/'
|
# coverage: '/TOTAL.*\s(\d+\.\d+)\%$/'
|
||||||
|
|
||||||
|
coftest:
|
||||||
|
stage: test
|
||||||
|
extends: .test_template
|
||||||
|
variables:
|
||||||
|
DJANGO_SETTINGS_MODULE: "cof.settings.cof_prod"
|
||||||
|
script:
|
||||||
|
- coverage run manage.py test gestioncof bda kfet petitscours shared --parallel
|
||||||
|
|
||||||
|
bdstest:
|
||||||
|
stage: test
|
||||||
|
extends: .test_template
|
||||||
|
variables:
|
||||||
|
DJANGO_SETTINGS_MODULE: "cof.settings.bds_prod"
|
||||||
|
script:
|
||||||
|
- coverage run manage.py test bds clubs events --parallel
|
||||||
|
|
||||||
linters:
|
linters:
|
||||||
stage: test
|
stage: test
|
||||||
before_script:
|
before_script:
|
||||||
|
@ -62,11 +74,13 @@ linters:
|
||||||
# Check whether there are some missing migrations.
|
# Check whether there are some missing migrations.
|
||||||
migration_checks:
|
migration_checks:
|
||||||
stage: test
|
stage: test
|
||||||
|
variables:
|
||||||
|
DJANGO_SETTINGS_MODULE: "cof.settings.local"
|
||||||
before_script:
|
before_script:
|
||||||
- mkdir -p vendor/{pip,apt}
|
- mkdir -p vendor/{pip,apt}
|
||||||
- apt-get update -q && apt-get -o dir::cache::archives="vendor/apt" install -yqq postgresql-client libldap2-dev libsasl2-dev
|
- apt-get update -q && apt-get -o dir::cache::archives="vendor/apt" install -yqq postgresql-client libldap2-dev libsasl2-dev
|
||||||
- cp cof/settings/secret_example.py cof/settings/secret.py
|
- cp cof/settings/secret_example.py cof/settings/secret.py
|
||||||
- pip install --upgrade -r requirements-prod.txt
|
- pip install --upgrade -r requirements-devel.txt
|
||||||
- python --version
|
- python --version
|
||||||
script: python manage.py makemigrations --dry-run --check
|
script: python manage.py makemigrations --dry-run --check
|
||||||
services:
|
services:
|
||||||
|
|
2
bds/urls.py
Normal file
2
bds/urls.py
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
app_label = "bds"
|
||||||
|
urlpatterns = []
|
|
@ -6,14 +6,15 @@ The settings that are not listed here are imported from .common
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from .common import * # NOQA
|
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 += ["bds", "events", "clubs"]
|
||||||
INSTALLED_APPS += ["events", "clubs"]
|
|
||||||
|
|
||||||
STATIC_ROOT = os.path.join(
|
STATIC_ROOT = os.path.join(
|
||||||
os.path.dirname(os.path.dirname(BASE_DIR)), "public", "gestion", "static"
|
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/"
|
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 os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
# ---
|
||||||
|
# Secrets
|
||||||
|
# ---
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from . import secret
|
from . import secret
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
@ -42,19 +46,19 @@ REDIS_DB = import_secret("REDIS_DB")
|
||||||
REDIS_HOST = import_secret("REDIS_HOST")
|
REDIS_HOST = import_secret("REDIS_HOST")
|
||||||
REDIS_PORT = import_secret("REDIS_PORT")
|
REDIS_PORT = import_secret("REDIS_PORT")
|
||||||
|
|
||||||
KFETOPEN_TOKEN = import_secret("KFETOPEN_TOKEN")
|
|
||||||
LDAP_SERVER_URL = import_secret("LDAP_SERVER_URL")
|
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__))))
|
BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||||
|
|
||||||
TESTING = sys.argv[1] == "test"
|
|
||||||
|
|
||||||
|
|
||||||
# Application definition
|
|
||||||
INSTALLED_APPS = [
|
INSTALLED_APPS = [
|
||||||
"shared",
|
"shared",
|
||||||
"gestioncof",
|
|
||||||
# Must be before 'django.contrib.admin'.
|
# Must be before 'django.contrib.admin'.
|
||||||
# https://django-autocomplete-light.readthedocs.io/en/master/install.html
|
# https://django-autocomplete-light.readthedocs.io/en/master/install.html
|
||||||
"dal",
|
"dal",
|
||||||
|
@ -64,51 +68,15 @@ INSTALLED_APPS = [
|
||||||
"django.contrib.sessions",
|
"django.contrib.sessions",
|
||||||
"django.contrib.sites",
|
"django.contrib.sites",
|
||||||
"django.contrib.messages",
|
"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.admin",
|
||||||
"django.contrib.admindocs",
|
"django.contrib.admindocs",
|
||||||
"bda",
|
"cof.apps.IgnoreSrcStaticFilesConfig",
|
||||||
"petitscours",
|
|
||||||
"captcha",
|
|
||||||
"django_cas_ng",
|
"django_cas_ng",
|
||||||
"bootstrapform",
|
"bootstrapform",
|
||||||
"kfet",
|
|
||||||
"kfet.open",
|
|
||||||
"channels",
|
|
||||||
"widget_tweaks",
|
"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 = [
|
MIDDLEWARE = [
|
||||||
"corsheaders.middleware.CorsMiddleware",
|
|
||||||
"django.contrib.sessions.middleware.SessionMiddleware",
|
"django.contrib.sessions.middleware.SessionMiddleware",
|
||||||
"django.middleware.common.CommonMiddleware",
|
"django.middleware.common.CommonMiddleware",
|
||||||
"django.middleware.csrf.CsrfViewMiddleware",
|
"django.middleware.csrf.CsrfViewMiddleware",
|
||||||
|
@ -116,9 +84,6 @@ MIDDLEWARE = [
|
||||||
"django.contrib.messages.middleware.MessageMiddleware",
|
"django.contrib.messages.middleware.MessageMiddleware",
|
||||||
"django.middleware.clickjacking.XFrameOptionsMiddleware",
|
"django.middleware.clickjacking.XFrameOptionsMiddleware",
|
||||||
"django.middleware.security.SecurityMiddleware",
|
"django.middleware.security.SecurityMiddleware",
|
||||||
"djconfig.middleware.DjConfigMiddleware",
|
|
||||||
"wagtail.core.middleware.SiteMiddleware",
|
|
||||||
"wagtail.contrib.redirects.middleware.RedirectMiddleware",
|
|
||||||
"django.middleware.locale.LocaleMiddleware",
|
"django.middleware.locale.LocaleMiddleware",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -127,7 +92,6 @@ ROOT_URLCONF = "cof.urls"
|
||||||
TEMPLATES = [
|
TEMPLATES = [
|
||||||
{
|
{
|
||||||
"BACKEND": "django.template.backends.django.DjangoTemplates",
|
"BACKEND": "django.template.backends.django.DjangoTemplates",
|
||||||
"DIRS": [],
|
|
||||||
"APP_DIRS": True,
|
"APP_DIRS": True,
|
||||||
"OPTIONS": {
|
"OPTIONS": {
|
||||||
"context_processors": [
|
"context_processors": [
|
||||||
|
@ -138,11 +102,6 @@ TEMPLATES = [
|
||||||
"django.template.context_processors.i18n",
|
"django.template.context_processors.i18n",
|
||||||
"django.template.context_processors.media",
|
"django.template.context_processors.media",
|
||||||
"django.template.context_processors.static",
|
"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
|
SITE_ID = 1
|
||||||
|
|
||||||
GRAPPELLI_ADMIN_HEADLINE = "GestioCOF"
|
|
||||||
GRAPPELLI_ADMIN_TITLE = '<a href="/">GestioCOF</a>'
|
|
||||||
|
|
||||||
MAIL_DATA = {
|
# ---
|
||||||
"petits_cours": {
|
# Internationalization
|
||||||
"FROM": "Le COF <cof@ens.fr>",
|
# https://docs.djangoproject.com/en/1.8/topics/i18n/
|
||||||
"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"
|
LANGUAGE_CODE = "fr-fr"
|
||||||
LOGIN_REDIRECT_URL = "home"
|
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_SERVER_URL = "https://cas.eleves.ens.fr/"
|
||||||
CAS_VERSION = "2"
|
CAS_VERSION = "2"
|
||||||
|
@ -203,37 +147,23 @@ CAS_IGNORE_REFERER = True
|
||||||
CAS_REDIRECT_URL = "/"
|
CAS_REDIRECT_URL = "/"
|
||||||
CAS_EMAIL_FORMAT = "%s@clipper.ens.fr"
|
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
|
# Cache settings
|
||||||
|
# ---
|
||||||
|
|
||||||
CACHES = {
|
CACHES = {
|
||||||
"default": {
|
"default": {
|
||||||
"BACKEND": "redis_cache.RedisCache",
|
"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
|
passwd=REDIS_PASSWD, host=REDIS_HOST, port=REDIS_PORT, db=REDIS_DB
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# ---
|
||||||
# Channels settings
|
# Channels settings
|
||||||
|
# ---
|
||||||
|
|
||||||
CHANNEL_LAYERS = {
|
CHANNEL_LAYERS = {
|
||||||
"default": {
|
"default": {
|
||||||
|
@ -253,16 +183,3 @@ CHANNEL_LAYERS = {
|
||||||
"ROUTING": "cof.routing.routing",
|
"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,55 +0,0 @@
|
||||||
"""
|
|
||||||
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 INSTALLED_APPS, MIDDLEWARE, TESTING
|
|
||||||
|
|
||||||
EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
|
|
||||||
|
|
||||||
DEBUG = True
|
|
||||||
|
|
||||||
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"]
|
|
||||||
|
|
||||||
|
|
||||||
# ---
|
|
||||||
# Apache static/media config
|
|
||||||
# ---
|
|
||||||
|
|
||||||
STATIC_URL = "/static/"
|
|
||||||
STATIC_ROOT = "/srv/gestiocof/static/"
|
|
||||||
|
|
||||||
MEDIA_ROOT = "/srv/gestiocof/media/"
|
|
||||||
MEDIA_URL = "/media/"
|
|
||||||
|
|
||||||
|
|
||||||
# ---
|
|
||||||
# Debug tool bar
|
|
||||||
# ---
|
|
||||||
|
|
||||||
|
|
||||||
def show_toolbar(request):
|
|
||||||
"""
|
|
||||||
On ne veut pas la vérification de INTERNAL_IPS faite par la debug-toolbar
|
|
||||||
car cela interfère avec l'utilisation de Vagrant. En effet, l'adresse de la
|
|
||||||
machine physique n'est pas forcément connue, et peut difficilement être
|
|
||||||
mise dans les INTERNAL_IPS.
|
|
||||||
"""
|
|
||||||
env_no_ddt = bool(os.environ.get("DJANGO_NO_DDT", None))
|
|
||||||
return DEBUG and not env_no_ddt and not request.path.startswith("/admin/")
|
|
||||||
|
|
||||||
|
|
||||||
if not TESTING:
|
|
||||||
INSTALLED_APPS += ["debug_toolbar"]
|
|
||||||
|
|
||||||
MIDDLEWARE = ["debug_toolbar.middleware.DebugToolbarMiddleware"] + MIDDLEWARE
|
|
||||||
|
|
||||||
DEBUG_TOOLBAR_CONFIG = {"SHOW_TOOLBAR_CALLBACK": show_toolbar}
|
|
|
@ -1,14 +1,36 @@
|
||||||
"""
|
"""Django local development settings."""
|
||||||
Django local settings for the cof project.
|
|
||||||
The settings that are not listed here are imported from .common
|
|
||||||
"""
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from .dev import * # NOQA
|
from . import bds_prod
|
||||||
from .dev import BASE_DIR
|
from .cof_prod import * # NOQA
|
||||||
|
from .cof_prod import BASE_DIR, INSTALLED_APPS, MIDDLEWARE, TESTING
|
||||||
|
|
||||||
|
# ---
|
||||||
|
# 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 = []
|
||||||
|
|
||||||
|
DEBUG = True
|
||||||
|
EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
|
||||||
|
|
||||||
|
if TESTING:
|
||||||
|
PASSWORD_HASHERS = ["django.contrib.auth.hashers.MD5PasswordHasher"]
|
||||||
|
|
||||||
|
STATIC_URL = "/static/"
|
||||||
|
MEDIA_URL = "/media/"
|
||||||
|
MEDIA_ROOT = os.path.join(BASE_DIR, "media")
|
||||||
|
|
||||||
# Use sqlite for local development
|
|
||||||
DATABASES = {
|
DATABASES = {
|
||||||
"default": {
|
"default": {
|
||||||
"ENGINE": "django.db.backends.sqlite3",
|
"ENGINE": "django.db.backends.sqlite3",
|
||||||
|
@ -27,5 +49,29 @@ CHANNEL_LAYERS = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# No need to run collectstatic -> unset STATIC_ROOT
|
|
||||||
STATIC_ROOT = None
|
# ---
|
||||||
|
# Debug tool bar
|
||||||
|
# ---
|
||||||
|
|
||||||
|
|
||||||
|
def show_toolbar(request):
|
||||||
|
"""
|
||||||
|
On active la debug-toolbar en mode développement local sauf :
|
||||||
|
- dans l'admin où ça ne sert pas à grand chose;
|
||||||
|
- si la variable d'environnement DJANGO_NO_DDT est à 1 → ça permet de la désactiver
|
||||||
|
sans modifier ce fichier en exécutant `export DJANGO_NO_DDT=1` dans le terminal
|
||||||
|
qui lance `./manage.py runserver`.
|
||||||
|
|
||||||
|
Autre side effect de cette fonction : on ne fait pas la vérification de INTERNAL_IPS
|
||||||
|
que ferait la debug-toolbar par défaut, ce qui la fait fonctionner aussi à
|
||||||
|
l'intérieur de Vagrant (comportement non testé depuis un moment…)
|
||||||
|
"""
|
||||||
|
env_no_ddt = bool(os.environ.get("DJANGO_NO_DDT", None))
|
||||||
|
return DEBUG and not env_no_ddt and not request.path.startswith("/admin/")
|
||||||
|
|
||||||
|
|
||||||
|
if not TESTING:
|
||||||
|
INSTALLED_APPS += ["debug_toolbar"]
|
||||||
|
MIDDLEWARE = ["debug_toolbar.middleware.DebugToolbarMiddleware"] + MIDDLEWARE
|
||||||
|
DEBUG_TOOLBAR_CONFIG = {"SHOW_TOOLBAR_CALLBACK": show_toolbar}
|
||||||
|
|
71
cof/urls.py
71
cof/urls.py
|
@ -8,27 +8,39 @@ from django.conf.urls.static import static
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.contrib.auth import views as django_auth_views
|
from django.contrib.auth import views as django_auth_views
|
||||||
from django.urls import include, path
|
from django.urls import include, path
|
||||||
from django.views.decorators.cache import cache_page
|
|
||||||
from django.views.generic.base import TemplateView
|
from django.views.generic.base import TemplateView
|
||||||
from django_cas_ng import views as django_cas_views
|
from django_cas_ng import views as django_cas_views
|
||||||
from django_js_reverse.views import urls_js
|
|
||||||
from wagtail.admin import urls as wagtailadmin_urls
|
|
||||||
from wagtail.core import urls as wagtail_urls
|
|
||||||
from wagtail.documents import urls as wagtaildocs_urls
|
|
||||||
|
|
||||||
from gestioncof import csv_views, views as gestioncof_views
|
admin.autodiscover()
|
||||||
from gestioncof.autocomplete import autocomplete
|
|
||||||
from gestioncof.urls import (
|
|
||||||
|
urlpatterns = [
|
||||||
|
path("admin/doc/", include("django.contrib.admindocs.urls")),
|
||||||
|
path("admin/", admin.site.urls),
|
||||||
|
]
|
||||||
|
|
||||||
|
if "gestioncof" in settings.INSTALLED_APPS:
|
||||||
|
from gestioncof import csv_views, views as gestioncof_views
|
||||||
|
from gestioncof.autocomplete import autocomplete
|
||||||
|
from gestioncof.urls import (
|
||||||
calendar_patterns,
|
calendar_patterns,
|
||||||
clubs_patterns,
|
clubs_patterns,
|
||||||
events_patterns,
|
events_patterns,
|
||||||
export_patterns,
|
export_patterns,
|
||||||
surveys_patterns,
|
surveys_patterns,
|
||||||
)
|
)
|
||||||
|
from django_js_reverse.views import urls_js
|
||||||
|
from wagtail.admin import urls as wagtailadmin_urls
|
||||||
|
from wagtail.documents import urls as wagtaildocs_urls
|
||||||
|
|
||||||
admin.autodiscover()
|
# Also includes BdA, K-Fêt, etc.
|
||||||
|
urlpatterns += [
|
||||||
urlpatterns = [
|
path("admin/logout/", gestioncof_views.logout),
|
||||||
|
path(
|
||||||
|
"admin/<slug:app_label>/<slug:model_name>/csv/",
|
||||||
|
csv_views.admin_list_export,
|
||||||
|
{"fields": ["username"]},
|
||||||
|
),
|
||||||
# Page d'accueil
|
# Page d'accueil
|
||||||
path("", gestioncof_views.HomeView.as_view(), name="home"),
|
path("", gestioncof_views.HomeView.as_view(), name="home"),
|
||||||
# Le BdA
|
# Le BdA
|
||||||
|
@ -54,10 +66,14 @@ urlpatterns = [
|
||||||
path("cas/login", django_cas_views.LoginView.as_view(), name="cas_login_view"),
|
path("cas/login", django_cas_views.LoginView.as_view(), name="cas_login_view"),
|
||||||
path("cas/logout", django_cas_views.LogoutView.as_view()),
|
path("cas/logout", django_cas_views.LogoutView.as_view()),
|
||||||
path(
|
path(
|
||||||
"outsider/login", gestioncof_views.LoginExtView.as_view(), name="ext_login_view"
|
"outsider/login",
|
||||||
|
gestioncof_views.LoginExtView.as_view(),
|
||||||
|
name="ext_login_view",
|
||||||
),
|
),
|
||||||
path(
|
path(
|
||||||
"outsider/logout", django_auth_views.LogoutView.as_view(), {"next_page": "home"}
|
"outsider/logout",
|
||||||
|
django_auth_views.LogoutView.as_view(),
|
||||||
|
{"next_page": "home"},
|
||||||
),
|
),
|
||||||
path("login", gestioncof_views.login, name="cof-login"),
|
path("login", gestioncof_views.login, name="cof-login"),
|
||||||
path("logout", gestioncof_views.logout, name="cof-logout"),
|
path("logout", gestioncof_views.logout, name="cof-logout"),
|
||||||
|
@ -92,22 +108,15 @@ urlpatterns = [
|
||||||
),
|
),
|
||||||
# Autocompletion
|
# Autocompletion
|
||||||
path(
|
path(
|
||||||
"autocomplete/registration", autocomplete, name="cof.registration.autocomplete"
|
"autocomplete/registration",
|
||||||
|
autocomplete,
|
||||||
|
name="cof.registration.autocomplete",
|
||||||
),
|
),
|
||||||
path(
|
path(
|
||||||
"user/autocomplete",
|
"user/autocomplete",
|
||||||
gestioncof_views.user_autocomplete,
|
gestioncof_views.user_autocomplete,
|
||||||
name="cof-user-autocomplete",
|
name="cof-user-autocomplete",
|
||||||
),
|
),
|
||||||
# Interface admin
|
|
||||||
path("admin/logout/", gestioncof_views.logout),
|
|
||||||
path("admin/doc/", include("django.contrib.admindocs.urls")),
|
|
||||||
path(
|
|
||||||
"admin/<slug:app_label>/<slug:model_name>/csv/",
|
|
||||||
csv_views.admin_list_export,
|
|
||||||
{"fields": ["username"]},
|
|
||||||
),
|
|
||||||
path("admin/", admin.site.urls),
|
|
||||||
# Liens utiles du COF et du BdA
|
# Liens utiles du COF et du BdA
|
||||||
path("utile_cof", gestioncof_views.utile_cof, name="utile_cof"),
|
path("utile_cof", gestioncof_views.utile_cof, name="utile_cof"),
|
||||||
path("utile_bda", gestioncof_views.utile_bda, name="utile_bda"),
|
path("utile_bda", gestioncof_views.utile_bda, name="utile_bda"),
|
||||||
|
@ -125,12 +134,15 @@ urlpatterns = [
|
||||||
path("config", gestioncof_views.ConfigUpdate.as_view(), name="config.edit"),
|
path("config", gestioncof_views.ConfigUpdate.as_view(), name="config.edit"),
|
||||||
# js-reverse
|
# js-reverse
|
||||||
path("jsreverse/", urls_js, name="js_reverse"),
|
path("jsreverse/", urls_js, name="js_reverse"),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
if "bds" in settings.INSTALLED_APPS:
|
||||||
|
urlpatterns.append(path("bds/", include("bds.urls")))
|
||||||
|
|
||||||
if "events" in settings.INSTALLED_APPS:
|
if "events" in settings.INSTALLED_APPS:
|
||||||
# The new event application is still in development
|
# The new event application is still in development
|
||||||
# → for now it is namespaced below events_v2
|
# → for now it is namespaced below events_v2
|
||||||
# → when the old events system is out, move this above in the others apps
|
# → rename this when the old events system is out
|
||||||
urlpatterns += [path("event_v2/", include("events.urls"))]
|
urlpatterns += [path("event_v2/", include("events.urls"))]
|
||||||
|
|
||||||
if "debug_toolbar" in settings.INSTALLED_APPS:
|
if "debug_toolbar" in settings.INSTALLED_APPS:
|
||||||
|
@ -144,6 +156,9 @@ if settings.DEBUG:
|
||||||
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||||
|
|
||||||
# Wagtail for uncatched
|
# Wagtail for uncatched
|
||||||
urlpatterns += i18n_patterns(
|
if "wagtail.core" in settings.INSTALLED_APPS:
|
||||||
|
from wagtail.core import urls as wagtail_urls
|
||||||
|
|
||||||
|
urlpatterns += i18n_patterns(
|
||||||
path("", include(wagtail_urls)), prefix_default_language=False
|
path("", include(wagtail_urls)), prefix_default_language=False
|
||||||
)
|
)
|
||||||
|
|
6
cof/wsgi.py
Normal file
6
cof/wsgi.py
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
import os
|
||||||
|
|
||||||
|
from django.core.wsgi import get_wsgi_application
|
||||||
|
|
||||||
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "cof.settings.bds_prod")
|
||||||
|
application = get_wsgi_application()
|
|
@ -1,5 +1,6 @@
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
from django.contrib.auth import get_user_model
|
from django.contrib.auth import get_user_model
|
||||||
from django.contrib.auth.models import Permission
|
from django.contrib.auth.models import Permission
|
||||||
from django.test import Client, TestCase
|
from django.test import Client, TestCase
|
||||||
|
@ -59,9 +60,8 @@ class CSVExportAccessTest(MessagePatch, TestCase):
|
||||||
def test_anonymous(self):
|
def test_anonymous(self):
|
||||||
client = Client()
|
client = Client()
|
||||||
r = client.get(self.url)
|
r = client.get(self.url)
|
||||||
self.assertRedirects(
|
login_url = "{}?next={}".format(reverse(settings.LOGIN_URL), self.url)
|
||||||
r, "/login?next={}".format(self.url), fetch_redirect_response=False
|
self.assertRedirects(r, login_url, fetch_redirect_response=False)
|
||||||
)
|
|
||||||
|
|
||||||
def test_unauthorised(self):
|
def test_unauthorised(self):
|
||||||
client = Client()
|
client = Client()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue