From ecb1eedcba706f49512b38229c4442448dd96fdc Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Sun, 8 Jan 2017 00:07:19 +0100 Subject: [PATCH] Add nav_topbar signal --- doc/development/api/general.rst | 2 +- src/pretix/control/context.py | 7 ++++- src/pretix/control/signals.py | 20 ++++++++++++- .../control/templates/pretixcontrol/base.html | 29 +++++++++++++++++++ 4 files changed, 55 insertions(+), 3 deletions(-) diff --git a/doc/development/api/general.rst b/doc/development/api/general.rst index 15cda410c6..0e064551ca 100644 --- a/doc/development/api/general.rst +++ b/doc/development/api/general.rst @@ -47,7 +47,7 @@ Backend ------- .. automodule:: pretix.control.signals - :members: nav_event, html_head, quota_detail_html + :members: nav_event, html_head, quota_detail_html, nav_topbar .. automodule:: pretix.base.signals diff --git a/src/pretix/control/context.py b/src/pretix/control/context.py index 79bcb89125..0b98224923 100644 --- a/src/pretix/control/context.py +++ b/src/pretix/control/context.py @@ -1,7 +1,7 @@ from django.conf import settings from django.core.urlresolvers import Resolver404, get_script_prefix, resolve -from .signals import html_head, nav_event +from .signals import html_head, nav_event, nav_topbar from .utils.i18n import get_javascript_format, get_moment_locale @@ -37,6 +37,11 @@ def contextprocessor(request): ctx['js_payment_weekdays_disabled'] = _js_payment_weekdays_disabled ctx['nav_event'] = _nav_event + _nav_topbar = [] + for receiver, response in nav_topbar.send(request, request=request): + _nav_topbar += response + ctx['nav_topbar'] = _nav_topbar + ctx['js_datetime_format'] = get_javascript_format('DATETIME_INPUT_FORMATS') ctx['js_date_format'] = get_javascript_format('DATE_INPUT_FORMATS') ctx['js_locale'] = get_moment_locale() diff --git a/src/pretix/control/signals.py b/src/pretix/control/signals.py index 841cd5c495..7d6edb1b57 100644 --- a/src/pretix/control/signals.py +++ b/src/pretix/control/signals.py @@ -28,7 +28,7 @@ nav_event = EventPluginSignal( ) """ This signal allows you to add additional views to the admin panel -navigation. You will get the request as a keyword argument ``return``. +navigation. You will get the request as a keyword argument ``request``. Receivers are expected to return a list of dictionaries. The dictionaries should contain at least the keys ``label`` and ``url``. You can also return a fontawesome icon name with the key ``icon``, it will be respected depending @@ -42,6 +42,24 @@ in pretix. As with all plugin signals, the ``sender`` keyword argument will contain the event. """ +nav_topbar = Signal( + providing_args=["request"] +) +""" +This signal allows you to add additional views to the top navigation bar. +You will get the request as a keyword argument ``return``. +Receivers are expected to return a list of dictionaries. The dictionaries +should contain at least the keys ``label`` and ``url``. You can also return +a fontawesome icon name with the key ``icon``, it will be respected depending +on the type of navigation. If set, on desktops only the ``icon`` will be shown. + +If you use this, you should read the documentation on :ref:`how to deal with URLs ` +in pretix. + +This is no ``EventPluginSignal``, so you do not get the event in the ``sender`` argument +and you may get the signal regardless of whether your plugin is active. +""" + event_dashboard_widgets = EventPluginSignal( providing_args=[] ) diff --git a/src/pretix/control/templates/pretixcontrol/base.html b/src/pretix/control/templates/pretixcontrol/base.html index d34e16db36..f6f1800dc7 100644 --- a/src/pretix/control/templates/pretixcontrol/base.html +++ b/src/pretix/control/templates/pretixcontrol/base.html @@ -74,6 +74,35 @@