add support for django 1.11 in settings (#21489)
This commit is contained in:
parent
ef66a13760
commit
d644728787
|
@ -11,7 +11,16 @@ DEBUG = False
|
|||
|
||||
STATIC_ROOT = '/var/lib/authentic2/collectstatic/'
|
||||
STATICFILES_DIRS = ('/var/lib/authentic2/static',) + STATICFILES_DIRS
|
||||
TEMPLATE_DIRS = ('/var/lib/authentic2/templates',) + TEMPLATE_DIRS
|
||||
|
||||
def update_templates_settings_dirs(dirs_to_add):
|
||||
return [
|
||||
dict(tpl, **{'DIRS': dirs_to_add + tpl['DIRS']})
|
||||
for tpl in TEMPLATES
|
||||
if tpl['BACKEND'] == 'django.template.backends.django.DjangoTemplates']
|
||||
|
||||
|
||||
TEMPLATES = update_templates_settings_dirs(('/var/lib/authentic2/templates',))
|
||||
|
||||
LOCALE_PATHS = ('/var/lib/authentic2/locale',) + LOCALE_PATHS
|
||||
|
||||
ADMINS = (('root', 'root@localhost'),)
|
||||
|
@ -297,6 +306,13 @@ def extract_settings_from_environ():
|
|||
pass
|
||||
globals()[setting_key] = value
|
||||
|
||||
# compatibility with django >= 1.8
|
||||
dirs = globals()['TEMPLATE_DIRS']
|
||||
del globals()['TEMPLATE_DIRS']
|
||||
globals()['TEMPLATES'] = update_templates_settings_dirs(dirs)
|
||||
|
||||
|
||||
|
||||
extract_settings_from_environ()
|
||||
|
||||
CONFIG_FILE = '/etc/authentic2/config.py'
|
||||
|
|
|
@ -13,7 +13,11 @@
|
|||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = False
|
||||
TEMPLATE_DEBUG = False
|
||||
|
||||
TEMPLATES = [
|
||||
dict(tpl, **{'OPTIONS': dict(tpl.get('OPTIONS', {}), **{'debug': False})})
|
||||
for tpl in TEMPLATES
|
||||
if tpl['BACKEND'] == 'django.template.backends.django.DjangoTemplates']
|
||||
|
||||
#ADMINS = (
|
||||
# # ('User 1', 'watchdog@example.net'),
|
||||
|
|
|
@ -11,7 +11,16 @@ DEBUG = False
|
|||
|
||||
STATIC_ROOT = '/var/lib/authentic2/collectstatic/'
|
||||
STATICFILES_DIRS = ('/var/lib/authentic2/static',) + STATICFILES_DIRS
|
||||
TEMPLATE_DIRS = ('/var/lib/authentic2/templates',) + TEMPLATE_DIRS
|
||||
|
||||
def update_templates_settings_dirs(dirs_to_add):
|
||||
return [
|
||||
dict(tpl, **{'DIRS': dirs_to_add + tpl['DIRS']})
|
||||
for tpl in TEMPLATES
|
||||
if tpl['BACKEND'] == 'django.template.backends.django.DjangoTemplates']
|
||||
|
||||
|
||||
TEMPLATES = update_templates_settings_dirs(('/var/lib/authentic2/templates',))
|
||||
|
||||
LOCALE_PATHS = ('/var/lib/authentic2/locale',) + LOCALE_PATHS
|
||||
|
||||
ADMINS = (('root', 'root@localhost'),)
|
||||
|
@ -295,6 +304,11 @@ def extract_settings_from_environ():
|
|||
pass
|
||||
globals()[setting_key] = value
|
||||
|
||||
# compatibility with django >= 1.8
|
||||
dirs = globals()['TEMPLATE_DIRS']
|
||||
del globals()['TEMPLATE_DIRS']
|
||||
globals()['TEMPLATES'] = update_templates_settings_dirs(dirs)
|
||||
|
||||
extract_settings_from_environ()
|
||||
|
||||
CONFIG_FILE = '/etc/authentic2/config.py'
|
||||
|
|
|
@ -13,7 +13,10 @@
|
|||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = False
|
||||
TEMPLATE_DEBUG = False
|
||||
TEMPLATES = [
|
||||
dict(tpl, **{'OPTIONS': dict(tpl.get('OPTIONS', {}), **{'debug': False})})
|
||||
for tpl in TEMPLATES
|
||||
if tpl['BACKEND'] == 'django.template.backends.django.DjangoTemplates']
|
||||
|
||||
#ADMINS = (
|
||||
# # ('User 1', 'watchdog@example.net'),
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import logging
|
||||
import logging.config
|
||||
# Load default from Django
|
||||
from django.conf.global_settings import *
|
||||
from django.conf.global_settings import STATICFILES_FINDERS, PASSWORD_HASHERS, MIGRATION_MODULES
|
||||
import os
|
||||
|
||||
import django
|
||||
|
@ -19,7 +19,6 @@ SECRET_KEY = 'please-change-me-with-a-very-long-random-string'
|
|||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = False
|
||||
DEBUG_DB = False
|
||||
TEMPLATE_DEBUG = False
|
||||
MEDIA = 'media'
|
||||
|
||||
# See https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts
|
||||
|
@ -46,17 +45,28 @@ USE_TZ = True
|
|||
|
||||
STATIC_URL = '/static/'
|
||||
|
||||
TEMPLATE_CONTEXT_PROCESSORS = (
|
||||
'django.contrib.auth.context_processors.auth',
|
||||
'django_rbac.context_processors.auth',
|
||||
'django.core.context_processors.debug',
|
||||
'django.core.context_processors.i18n',
|
||||
'django.core.context_processors.media',
|
||||
'django.core.context_processors.request',
|
||||
'django.contrib.messages.context_processors.messages',
|
||||
'django.core.context_processors.static',
|
||||
'authentic2.context_processors.a2_processor',
|
||||
)
|
||||
# TEMPLATES compatible dj >= 1.8
|
||||
TEMPLATES = [
|
||||
{
|
||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||
'DIRS': (os.path.join(BASE_DIR, 'templates'),),
|
||||
'OPTIONS': {
|
||||
'debug': False,
|
||||
'context_processors': [
|
||||
'django.contrib.auth.context_processors.auth',
|
||||
'django_rbac.context_processors.auth',
|
||||
'django.template.context_processors.debug',
|
||||
'django.template.context_processors.i18n',
|
||||
'django.template.context_processors.media',
|
||||
'django.template.context_processors.request',
|
||||
'django.contrib.messages.context_processors.messages',
|
||||
'django.template.context_processors.static',
|
||||
'authentic2.context_processors.a2_processor',
|
||||
],
|
||||
'loaders': ['django.template.loaders.app_directories.Loader']
|
||||
}
|
||||
},
|
||||
]
|
||||
|
||||
MIDDLEWARE_CLASSES = (
|
||||
'authentic2.middleware.StoreRequestMiddleware',
|
||||
|
@ -70,11 +80,6 @@ MIDDLEWARE_CLASSES = (
|
|||
'django.middleware.locale.LocaleMiddleware',
|
||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
)
|
||||
|
||||
DATABASES['default']['ATOMIC_REQUESTS'] = True
|
||||
|
||||
MIDDLEWARE_CLASSES += (
|
||||
'authentic2.middleware.DisplayMessageBeforeRedirectMiddleware',
|
||||
'authentic2.idp.middleware.DebugMiddleware',
|
||||
'authentic2.middleware.CollectIPMiddleware',
|
||||
|
@ -82,15 +87,19 @@ MIDDLEWARE_CLASSES += (
|
|||
'authentic2.middleware.OpenedSessionCookieMiddleware',
|
||||
)
|
||||
|
||||
DATABASES['default']['ATOMIC_REQUESTS'] = True
|
||||
|
||||
MIDDLEWARE_CLASSES = plugins.register_plugins_middleware(MIDDLEWARE_CLASSES)
|
||||
|
||||
ROOT_URLCONF = 'authentic2.urls'
|
||||
|
||||
TEMPLATE_DIRS = (os.path.join(BASE_DIR, 'templates'),)
|
||||
|
||||
STATICFILES_DIRS = (os.path.join(BASE_DIR, 'static'),)
|
||||
|
||||
STATICFILES_FINDERS = STATICFILES_FINDERS + ('gadjo.finders.XStaticFinder',)
|
||||
# Django 1.8 : default settings are tuples. from version 1.9 default settings are lists
|
||||
if STATICFILES_FINDERS and isinstance(STATICFILES_FINDERS, tuple):
|
||||
STATICFILES_FINDERS = list(STATICFILES_FINDERS)
|
||||
|
||||
STATICFILES_FINDERS += STATICFILES_FINDERS
|
||||
|
||||
LOCALE_PATHS = ( os.path.join(BASE_DIR, 'locale'), )
|
||||
|
||||
|
@ -101,10 +110,6 @@ INSTALLED_APPS = (
|
|||
'django.contrib.auth',
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.messages',
|
||||
'admin_tools',
|
||||
'admin_tools.theming',
|
||||
'admin_tools.menu',
|
||||
'admin_tools.dashboard',
|
||||
'django.contrib.admin',
|
||||
'django_select2',
|
||||
'django_tables2',
|
||||
|
@ -177,20 +182,17 @@ IDP_BACKENDS = plugins.register_plugins_idp_backends(())
|
|||
# Whether to autoload SAML 2.0 identity providers and services metadata
|
||||
# Only https URLS are accepted.
|
||||
# Can be none, sp, idp or both
|
||||
if PASSWORD_HASHERS and isinstance(PASSWORD_HASHERS, tuple):
|
||||
PASSWORD_HASHERS = list(PASSWORD_HASHERS)
|
||||
|
||||
PASSWORD_HASHERS += (
|
||||
'authentic2.hashers.Drupal7PasswordHasher',
|
||||
'authentic2.hashers.SHA256PasswordHasher',
|
||||
'authentic2.hashers.SSHA1PasswordHasher',
|
||||
'authentic2.hashers.SMD5PasswordHasher',
|
||||
'authentic2.hashers.SHA1OLDAPPasswordHasher',
|
||||
'authentic2.hashers.MD5OLDAPPasswordHasher',
|
||||
)
|
||||
|
||||
# Admin tools
|
||||
ADMIN_TOOLS_INDEX_DASHBOARD = 'authentic2.dashboard.CustomIndexDashboard'
|
||||
ADMIN_TOOLS_APP_INDEX_DASHBOARD = 'authentic2.dashboard.CustomAppIndexDashboard'
|
||||
ADMIN_TOOLS_MENU = 'authentic2.menu.CustomMenu'
|
||||
PASSWORD_HASHERS += [
|
||||
'authentic2.hashers.Drupal7PasswordHasher',
|
||||
'authentic2.hashers.SHA256PasswordHasher',
|
||||
'authentic2.hashers.SSHA1PasswordHasher',
|
||||
'authentic2.hashers.SMD5PasswordHasher',
|
||||
'authentic2.hashers.SHA1OLDAPPasswordHasher',
|
||||
'authentic2.hashers.MD5OLDAPPasswordHasher'
|
||||
]
|
||||
|
||||
# Serialization module to support natural keys in generic foreign keys
|
||||
SERIALIZATION_MODULES = {
|
||||
|
@ -264,11 +266,6 @@ LOGGING = {
|
|||
},
|
||||
}
|
||||
|
||||
MIGRATION_MODULES = {
|
||||
'auth': 'authentic2.auth_migrations',
|
||||
'menu': 'authentic2.menu_migrations',
|
||||
'dashboard': 'authentic2.dashboard_migrations',
|
||||
}
|
||||
if django.VERSION >= (1,8):
|
||||
MIGRATION_MODULES['auth'] = 'authentic2.auth_migrations_18'
|
||||
|
||||
|
@ -309,7 +306,7 @@ DJANGO_RBAC_PERMISSIONS_HIERARCHY = {
|
|||
'add': ['view', 'search'],
|
||||
}
|
||||
|
||||
SILENCED_SYSTEM_CHECKS = ["auth.W004"]
|
||||
SILENCED_SYSTEM_CHECKS = ["auth.W004", "auth.C009", "auth.C010"]
|
||||
|
||||
# Get select2 from local copy.
|
||||
SELECT2_JS = xstatic('select2', 'select2.min.js')
|
||||
|
|
|
@ -4,7 +4,7 @@ import os
|
|||
if 'PASSWORD_HASHERS' not in locals():
|
||||
from django.conf.global_settings import PASSWORD_HASHERS
|
||||
|
||||
PASSWORD_HASHERS = ('django.contrib.auth.hashers.UnsaltedMD5PasswordHasher',) + PASSWORD_HASHERS
|
||||
PASSWORD_HASHERS = ['django.contrib.auth.hashers.UnsaltedMD5PasswordHasher'] + list(PASSWORD_HASHERS)
|
||||
|
||||
A2_CACHE_ENABLED = False
|
||||
|
||||
|
@ -17,3 +17,5 @@ DATABASES = {
|
|||
},
|
||||
}
|
||||
}
|
||||
|
||||
ALLOWED_HOSTS = ['example.com', 'cache1.exemple.com', 'cache2.example.com']
|
Loading…
Reference in New Issue