context_processors: add settings.TEMPLATE_VARS in template context

It's better to remove configuration from templates.
This commit is contained in:
Benjamin Dauvergne 2014-07-02 11:03:01 +02:00
parent 83a0d42b05
commit 95e407a783
2 changed files with 10 additions and 3 deletions

View File

@ -1,3 +1,5 @@
from django.conf import settings
from . import utils
class UserFederations(object):
@ -22,5 +24,8 @@ class UserFederations(object):
return d
return super(UserFederations, self).__getattr__(name)
def federations_processor(request):
return {'federations': UserFederations(request) }
def a2_processor(request):
variables = {}
variables.update(getattr(settings, 'TEMPLATE_VARS', {}))
variables['federations'] = UserFederations(request)
return variables

View File

@ -105,7 +105,7 @@ TEMPLATE_CONTEXT_PROCESSORS = (
'django.core.context_processors.request',
'django.contrib.messages.context_processors.messages',
'django.core.context_processors.static',
'authentic2.context_processors.federations_processor',
'authentic2.context_processors.a2_processor',
)
MIDDLEWARE_CLASSES = (
@ -145,6 +145,8 @@ STATICFILES_DIRS = (
if os.environ.get('TEMPLATE_DIRS'):
TEMPLATE_DIRS = tuple(os.environ['TEMPLATE_DIRS'].split(':')) + TEMPLATE_DIRS
TEMPLATE_VARS = {}
if os.environ.get('STATICFILES_DIRS'):
STATICFILES_DIRS = tuple(os.environ['STATICFILES_DIRS'].split(':')) + STATICFILES_DIRS