mirror of https://gitlab.crans.org/bde/nk20
modular settings start
This commit is contained in:
parent
46a65a8f16
commit
30fb311b2e
|
@ -33,14 +33,42 @@ if app_stage == 'prod':
|
||||||
|
|
||||||
DATABASES["default"]["PASSWORD"] = os.environ.get('DJANGO_DB_PASSWORD', 'CHANGE_ME_IN_ENV_SETTINGS')
|
DATABASES["default"]["PASSWORD"] = os.environ.get('DJANGO_DB_PASSWORD', 'CHANGE_ME_IN_ENV_SETTINGS')
|
||||||
SECRET_KEY = os.environ.get('DJANGO_SECRET_KEY', 'CHANGE_ME_IN_ENV_SETTINGS')
|
SECRET_KEY = os.environ.get('DJANGO_SECRET_KEY', 'CHANGE_ME_IN_ENV_SETTINGS')
|
||||||
ALLOWED_HOSTS.append(os.environ.get('ALLOWED_HOSTS', 'localhost'))
|
ALLOWED_HOSTS = [os.environ.get('ALLOWED_HOSTS', 'localhost')]
|
||||||
else:
|
else:
|
||||||
from .development import *
|
from .development import *
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
#in secrets.py defines everything you want
|
||||||
from .secrets import *
|
from .secrets import *
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# env variables set at the of in /env/bin/activate
|
if "cas" in INSTALLED_APPS:
|
||||||
# don't forget to unset in deactivate !
|
MIDDLEWARE += ['cas.middleware.CASMiddleware']
|
||||||
|
# CAS Settings
|
||||||
|
CAS_AUTO_CREATE_USER = False
|
||||||
|
CAS_LOGO_URL = "/static/img/Saperlistpopette.png"
|
||||||
|
CAS_FAVICON_URL = "/static/favicon/favicon-32x32.png"
|
||||||
|
CAS_SHOW_SERVICE_MESSAGES = True
|
||||||
|
CAS_SHOW_POWERED = False
|
||||||
|
CAS_REDIRECT_TO_LOGIN_AFTER_LOGOUT = False
|
||||||
|
CAS_INFO_MESSAGES = {
|
||||||
|
"cas_explained": {
|
||||||
|
"message": _(
|
||||||
|
u"The Central Authentication Service grants you access to most of our websites by "
|
||||||
|
u"authenticating only once, so you don't need to type your credentials again unless "
|
||||||
|
u"your session expires or you logout."
|
||||||
|
),
|
||||||
|
"discardable": True,
|
||||||
|
"type": "info", # one of info, success, info, warning, danger
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
CAS_INFO_MESSAGES_ORDER = [
|
||||||
|
'cas_explained',
|
||||||
|
]
|
||||||
|
AUTHENTICATION_BACKENDS += ('cas.backends.CASBackend',)
|
||||||
|
|
||||||
|
if "debug_toolbar" in INSTALLED_APPS:
|
||||||
|
MIDDLEWARE.insert(1,"debug_toolbar.middleware.DebugToolbarMiddleware")
|
||||||
|
INTERNAL_IPS = [ '127.0.0.1']
|
||||||
|
|
|
@ -55,9 +55,6 @@ INSTALLED_APPS = [
|
||||||
# Autocomplete
|
# Autocomplete
|
||||||
'dal',
|
'dal',
|
||||||
'dal_select2',
|
'dal_select2',
|
||||||
# CAS
|
|
||||||
'cas_server',
|
|
||||||
'cas',
|
|
||||||
|
|
||||||
# Note apps
|
# Note apps
|
||||||
'activity',
|
'activity',
|
||||||
|
@ -80,7 +77,6 @@ MIDDLEWARE = [
|
||||||
'django.middleware.locale.LocaleMiddleware',
|
'django.middleware.locale.LocaleMiddleware',
|
||||||
'django.contrib.sites.middleware.CurrentSiteMiddleware',
|
'django.contrib.sites.middleware.CurrentSiteMiddleware',
|
||||||
'note_kfet.middlewares.TurbolinksMiddleware',
|
'note_kfet.middlewares.TurbolinksMiddleware',
|
||||||
'cas.middleware.CASMiddleware',
|
|
||||||
]
|
]
|
||||||
|
|
||||||
ROOT_URLCONF = 'note_kfet.urls'
|
ROOT_URLCONF = 'note_kfet.urls'
|
||||||
|
@ -134,7 +130,6 @@ PASSWORD_HASHERS = [
|
||||||
AUTHENTICATION_BACKENDS = (
|
AUTHENTICATION_BACKENDS = (
|
||||||
'django.contrib.auth.backends.ModelBackend', # this is default
|
'django.contrib.auth.backends.ModelBackend', # this is default
|
||||||
'guardian.backends.ObjectPermissionBackend',
|
'guardian.backends.ObjectPermissionBackend',
|
||||||
'cas.backends.CASBackend',
|
|
||||||
)
|
)
|
||||||
|
|
||||||
REST_FRAMEWORK = {
|
REST_FRAMEWORK = {
|
||||||
|
@ -201,26 +196,3 @@ MEDIA_URL = '/media/'
|
||||||
# Profile Picture Settings
|
# Profile Picture Settings
|
||||||
PIC_WIDTH = 200
|
PIC_WIDTH = 200
|
||||||
PIC_RATIO = 1
|
PIC_RATIO = 1
|
||||||
|
|
||||||
# CAS Settings
|
|
||||||
CAS_AUTO_CREATE_USER = False
|
|
||||||
CAS_LOGO_URL = "/static/img/Saperlistpopette.png"
|
|
||||||
CAS_FAVICON_URL = "/static/favicon/favicon-32x32.png"
|
|
||||||
CAS_SHOW_SERVICE_MESSAGES = True
|
|
||||||
CAS_SHOW_POWERED = False
|
|
||||||
CAS_REDIRECT_TO_LOGIN_AFTER_LOGOUT = False
|
|
||||||
CAS_INFO_MESSAGES = {
|
|
||||||
"cas_explained": {
|
|
||||||
"message": _(
|
|
||||||
u"The Central Authentication Service grants you access to most of our websites by "
|
|
||||||
u"authenticating only once, so you don't need to type your credentials again unless "
|
|
||||||
u"your session expires or you logout."
|
|
||||||
),
|
|
||||||
"discardable": True,
|
|
||||||
"type": "info", # one of info, success, info, warning, danger
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
CAS_INFO_MESSAGES_ORDER = [
|
|
||||||
'cas_explained',
|
|
||||||
]
|
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
# CAS
|
||||||
|
OPTIONAL_APPS = [
|
||||||
|
# 'cas_server',
|
||||||
|
# 'cas',
|
||||||
|
# 'debug_toolbar'
|
||||||
|
]
|
|
@ -1,7 +1,6 @@
|
||||||
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
|
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
from cas import views as cas_views
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.conf.urls.static import static
|
from django.conf.urls.static import static
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
@ -15,25 +14,40 @@ urlpatterns = [
|
||||||
# Include project routers
|
# Include project routers
|
||||||
path('note/', include('note.urls')),
|
path('note/', include('note.urls')),
|
||||||
|
|
||||||
# Include CAS Client routers
|
|
||||||
path('accounts/login/', cas_views.login, name='login'),
|
|
||||||
path('accounts/logout/', cas_views.logout, name='logout'),
|
|
||||||
|
|
||||||
# Include Django Contrib and Core routers
|
# Include Django Contrib and Core routers
|
||||||
path('i18n/', include('django.conf.urls.i18n')),
|
path('i18n/', include('django.conf.urls.i18n')),
|
||||||
path('accounts/', include('member.urls')),
|
path('accounts/', include('member.urls')),
|
||||||
path('accounts/', include('django.contrib.auth.urls')),
|
path('accounts/', include('django.contrib.auth.urls')),
|
||||||
path('admin/doc/', include('django.contrib.admindocs.urls')),
|
path('admin/doc/', include('django.contrib.admindocs.urls')),
|
||||||
path('admin/', admin.site.urls),
|
path('admin/', admin.site.urls),
|
||||||
|
|
||||||
# Include CAS Server routers
|
|
||||||
path('cas/', include('cas_server.urls', namespace="cas_server")),
|
|
||||||
|
|
||||||
# Include Django REST API
|
|
||||||
path('api/', include('api.urls')),
|
|
||||||
|
|
||||||
path('logs/', include('logs.urls')),
|
path('logs/', include('logs.urls')),
|
||||||
]
|
]
|
||||||
|
|
||||||
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||||
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
|
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
|
||||||
|
|
||||||
|
|
||||||
|
if "cas_server" in settings.INSTALLED_APPS:
|
||||||
|
urlpatterns += [
|
||||||
|
# Include CAS Server routers
|
||||||
|
path('cas/', include('cas_server.urls', namespace="cas_server")),
|
||||||
|
]
|
||||||
|
if "cas" in settings.INSTALLED_APPS:
|
||||||
|
from cas import views as cas_views
|
||||||
|
urlpatterns += [
|
||||||
|
# Include CAS Client routers
|
||||||
|
path('accounts/login/', cas_views.login, name='login'),
|
||||||
|
path('accounts/logout/', cas_views.logout, name='logout'),
|
||||||
|
|
||||||
|
]
|
||||||
|
if "debug_toolbar" in settings.INSTALLED_APPS:
|
||||||
|
import debug_toolbar
|
||||||
|
urlpatterns = [
|
||||||
|
path('__debug__/', include(debug_toolbar.urls)),
|
||||||
|
] + urlpatterns
|
||||||
|
|
||||||
|
if "api" in settings.INSTALLED_APPS:
|
||||||
|
# Include Django REST API
|
||||||
|
urlpatterns += [
|
||||||
|
path('api/', include('api.urls')),
|
||||||
|
]
|
||||||
|
|
Loading…
Reference in New Issue