Files
pretix_original/src/pretix/control/context.py
2015-03-21 22:03:39 +01:00

29 lines
833 B
Python

from django.conf import settings
from django.core.urlresolvers import resolve
from .signals import html_head, nav_event
def contextprocessor(request):
"""
Adds data to all template contexts
"""
url = resolve(request.path_info)
if not request.path.startswith('/control'):
return {}
ctx = {
'url_name': url.url_name,
'settings': settings,
}
_html_head = []
if hasattr(request, 'event'):
for receiver, response in html_head.send(request.event, request=request):
_html_head.append(response)
ctx['html_head'] = "".join(_html_head)
_nav_event = []
if hasattr(request, 'event'):
for receiver, response in nav_event.send(request.event, request=request):
_nav_event += response
ctx['nav_event'] = _nav_event
return ctx