Skip to content

Commit d4a76a7

Browse files
Refactor Navigation Signals for Dashboard Separation (#528)
* FMT Fix * Undoing Initial PR code --------- Co-authored-by: Daksh Bhayana <[email protected]>
1 parent 2284565 commit d4a76a7

File tree

3 files changed

+31
-4
lines changed

3 files changed

+31
-4
lines changed

src/pretix/eventyay_common/navigation.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66

77
from pretix.base.models import Event
88
from pretix.control.navigation import merge_in
9-
from pretix.control.signals import nav_event, nav_global
9+
from pretix.control.signals import nav_global
10+
from pretix.eventyay_common.signals import nav_event_common
1011

1112

1213
def get_global_navigation(request: HttpRequest) -> List[Dict[str, Any]]:
@@ -92,7 +93,7 @@ def get_event_navigation(request: HttpRequest, event: Event) -> List[Dict[str, A
9293
]
9394

9495
# Merge plugin-provided navigation items
95-
plugin_responses = nav_event.send(event, request=request)
96+
plugin_responses = nav_event_common.send(event, request=request)
9697
plugin_nav_items = []
9798
for receiver, response in plugin_responses:
9899
if response:

src/pretix/eventyay_common/signals.py

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
from pretix.base.signals import EventPluginSignal
2+
3+
nav_event_common = EventPluginSignal()
4+
"""
5+
Arguments: ``request``
6+
7+
This signal allows you to add additional views to the common sidebar navigation.
8+
You will get the request as a keyword argument ``request``.
9+
Receivers are expected to return a list of dictionaries. The dictionaries
10+
should contain at least the keys ``label`` and ``url``. You can also return
11+
a fontawesome icon name with the key ``icon``, it will be respected depending
12+
on the type of navigation. You should also return an ``active`` key with a boolean
13+
set to ``True``, when this item should be marked as active. The ``request`` object
14+
will have an attribute ``event``.
15+
16+
You can optionally create sub-items to create hierarchical navigation. There are two
17+
ways to achieve this: Either you specify a key ``children`` on your top navigation item
18+
that contains a list of navigation items (as dictionaries), or you specify a ``parent``
19+
key with the ``url`` value of the designated parent item.
20+
The latter method also allows you to register navigation items as a sub-item of existing ones.
21+
22+
If you use this, you should read the documentation on :ref:`how to deal with URLs <urlconf>`
23+
in pretix.
24+
25+
As with all plugin signals, the ``sender`` keyword argument will contain the event.
26+
"""

src/pretix/plugins/webcheckin/signals.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
from django.utils.safestring import mark_safe
44
from django.utils.translation import gettext_lazy as _
55

6-
from pretix.control.signals import nav_event
6+
from pretix.eventyay_common.signals import nav_event_common
77

88

9-
@receiver(nav_event, dispatch_uid='webcheckin_nav_event')
9+
@receiver(nav_event_common, dispatch_uid='webcheckin_nav_event')
1010
def navbar_entry(sender, request, **kwargs):
1111
url = request.resolver_match
1212
if not request.user.has_event_permission(request.organizer, request.event, ('can_change_orders', 'can_checkin_orders'), request=request):

0 commit comments

Comments
 (0)