mirror of
https://github.com/pretix/pretix.git
synced 2026-05-11 16:13:59 +00:00
Add signal nav_global
This commit is contained in:
@@ -47,7 +47,7 @@ Backend
|
|||||||
-------
|
-------
|
||||||
|
|
||||||
.. automodule:: pretix.control.signals
|
.. automodule:: pretix.control.signals
|
||||||
:members: nav_event, html_head, quota_detail_html, nav_topbar, organizer_edit_tabs
|
:members: nav_event, html_head, quota_detail_html, nav_topbar, nav_global, organizer_edit_tabs
|
||||||
|
|
||||||
|
|
||||||
.. automodule:: pretix.base.signals
|
.. automodule:: pretix.base.signals
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ from django.core.urlresolvers import Resolver404, get_script_prefix, resolve
|
|||||||
|
|
||||||
from pretix.base.settings import GlobalSettingsObject
|
from pretix.base.settings import GlobalSettingsObject
|
||||||
|
|
||||||
from .signals import html_head, nav_event, nav_topbar
|
from .signals import html_head, nav_event, nav_global, nav_topbar
|
||||||
from .utils.i18n import get_javascript_format, get_moment_locale
|
from .utils.i18n import get_javascript_format, get_moment_locale
|
||||||
|
|
||||||
|
|
||||||
@@ -38,8 +38,14 @@ def contextprocessor(request):
|
|||||||
_nav_event += response
|
_nav_event += response
|
||||||
if request.event.settings.get('payment_term_weekdays'):
|
if request.event.settings.get('payment_term_weekdays'):
|
||||||
_js_payment_weekdays_disabled = '[0,6]'
|
_js_payment_weekdays_disabled = '[0,6]'
|
||||||
ctx['js_payment_weekdays_disabled'] = _js_payment_weekdays_disabled
|
|
||||||
ctx['nav_event'] = _nav_event
|
ctx['nav_event'] = _nav_event
|
||||||
|
ctx['js_payment_weekdays_disabled'] = _js_payment_weekdays_disabled
|
||||||
|
|
||||||
|
_nav_global = []
|
||||||
|
if not hasattr(request, 'event'):
|
||||||
|
for receiver, response in nav_global.send(request, request=request):
|
||||||
|
_nav_global += response
|
||||||
|
ctx['nav_global'] = _nav_global
|
||||||
|
|
||||||
_nav_topbar = []
|
_nav_topbar = []
|
||||||
for receiver, response in nav_topbar.send(request, request=request):
|
for receiver, response in nav_topbar.send(request, request=request):
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ nav_topbar = Signal(
|
|||||||
)
|
)
|
||||||
"""
|
"""
|
||||||
This signal allows you to add additional views to the top navigation bar.
|
This signal allows you to add additional views to the top navigation bar.
|
||||||
You will get the request as a keyword argument ``return``.
|
You will get the request as a keyword argument ``request``.
|
||||||
Receivers are expected to return a list of dictionaries. The dictionaries
|
Receivers are expected to return a list of dictionaries. The dictionaries
|
||||||
should contain at least the keys ``label`` and ``url``. You can also return
|
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
|
a fontawesome icon name with the key ``icon``, it will be respected depending
|
||||||
@@ -61,6 +61,25 @@ This is no ``EventPluginSignal``, so you do not get the event in the ``sender``
|
|||||||
and you may get the signal regardless of whether your plugin is active.
|
and you may get the signal regardless of whether your plugin is active.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
nav_global = Signal(
|
||||||
|
providing_args=["request"]
|
||||||
|
)
|
||||||
|
"""
|
||||||
|
This signal allows you to add additional views to the navigation bar when no event is
|
||||||
|
selected. 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
|
||||||
|
on the type of navigation. You should also return an ``active`` key with a boolean
|
||||||
|
set to ``True``, when this item should be marked as active.
|
||||||
|
|
||||||
|
If you use this, you should read the documentation on :ref:`how to deal with URLs <urlconf>`
|
||||||
|
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(
|
event_dashboard_widgets = EventPluginSignal(
|
||||||
providing_args=[]
|
providing_args=[]
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -168,6 +168,32 @@
|
|||||||
{% trans "Organizers" %}
|
{% trans "Organizers" %}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
{% for nav in nav_global %}
|
||||||
|
<li>
|
||||||
|
<a href="{{ nav.url }}" {% if nav.active %}class="active"{% endif %}
|
||||||
|
{% if nav.children %}class="has-children"{% endif %}>
|
||||||
|
{% if nav.icon %}
|
||||||
|
<i class="fa fa-{{ nav.icon }} fa-fw"></i>
|
||||||
|
{% endif %}
|
||||||
|
{{ nav.label }}
|
||||||
|
</a>
|
||||||
|
{% if nav.children %}
|
||||||
|
<a href="#" class="arrow">
|
||||||
|
<span class="fa arrow"></span>
|
||||||
|
</a>
|
||||||
|
<ul class="nav nav-second-level">
|
||||||
|
{% for item in nav.children %}
|
||||||
|
<li>
|
||||||
|
<a href="{{ item.url }}"
|
||||||
|
{% if item.active %}class="active"{% endif %}>
|
||||||
|
{{ item.label }}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
{% endif %}
|
||||||
|
</li>
|
||||||
|
{% endfor %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user