mirror of
https://github.com/pretix/pretix.git
synced 2026-05-09 15:54:03 +00:00
Add new signal nav_item
This commit is contained in:
@@ -45,7 +45,7 @@ Backend
|
|||||||
|
|
||||||
.. automodule:: pretix.control.signals
|
.. automodule:: pretix.control.signals
|
||||||
:members: nav_event, html_head, html_page_start, quota_detail_html, nav_topbar, nav_global, nav_organizer, nav_event_settings,
|
:members: nav_event, html_head, html_page_start, quota_detail_html, nav_topbar, nav_global, nav_organizer, nav_event_settings,
|
||||||
order_info, event_settings_widget, oauth_application_registered, order_position_buttons
|
order_info, event_settings_widget, oauth_application_registered, order_position_buttons, nav_item
|
||||||
|
|
||||||
|
|
||||||
.. automodule:: pretix.base.signals
|
.. automodule:: pretix.base.signals
|
||||||
|
|||||||
@@ -237,6 +237,24 @@ As with all plugin signals, the ``sender`` keyword argument will contain the eve
|
|||||||
A second keyword argument ``request`` will contain the request object.
|
A second keyword argument ``request`` will contain the request object.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
nav_item = EventPluginSignal(
|
||||||
|
providing_args=['request', 'item']
|
||||||
|
)
|
||||||
|
"""
|
||||||
|
This signal is sent out to include tab links on the settings page of an item.
|
||||||
|
Receivers are expected to return a list of dictionaries. The dictionaries
|
||||||
|
should contain at least the keys ``label`` and ``url``. You should also return
|
||||||
|
an ``active`` key with a boolean set to ``True``, when this item should be marked
|
||||||
|
as active.
|
||||||
|
|
||||||
|
If your linked view should stay in the tab-like context of this page, we recommend
|
||||||
|
that you use ``pretix.control.views.item.ItemDetailMixin`` for your view
|
||||||
|
and your template inherits from ``pretixcontrol/item/base.html``.
|
||||||
|
|
||||||
|
As with all plugin signals, the ``sender`` keyword argument will contain the event.
|
||||||
|
A second keyword argument ``request`` will contain the request object.
|
||||||
|
"""
|
||||||
|
|
||||||
event_settings_widget = EventPluginSignal(
|
event_settings_widget = EventPluginSignal(
|
||||||
providing_args=['request']
|
providing_args=['request']
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -27,6 +27,13 @@
|
|||||||
{% trans "Bundled products" %}
|
{% trans "Bundled products" %}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
{% for n in extra_nav %}
|
||||||
|
<li {% if n.active %}class="active"{% endif %}>
|
||||||
|
<a href="{{ n.url }}">
|
||||||
|
{{ n.label }}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
{% else %}
|
{% else %}
|
||||||
<h1>{% trans "Create product" %}</h1>
|
<h1>{% trans "Create product" %}</h1>
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ from pretix.control.forms.item import (
|
|||||||
from pretix.control.permissions import (
|
from pretix.control.permissions import (
|
||||||
EventPermissionRequiredMixin, event_permission_required,
|
EventPermissionRequiredMixin, event_permission_required,
|
||||||
)
|
)
|
||||||
from pretix.control.signals import item_forms
|
from pretix.control.signals import item_forms, nav_item
|
||||||
|
|
||||||
from . import ChartContainingView, CreateView, PaginationMixin, UpdateView
|
from . import ChartContainingView, CreateView, PaginationMixin, UpdateView
|
||||||
|
|
||||||
@@ -782,6 +782,18 @@ class ItemDetailMixin(SingleObjectMixin):
|
|||||||
model = Item
|
model = Item
|
||||||
context_object_name = 'item'
|
context_object_name = 'item'
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
ctx = super().get_context_data(**kwargs)
|
||||||
|
nav = sorted(
|
||||||
|
sum(
|
||||||
|
(list(a[1]) for a in nav_item.send(self.request.event, request=self.request, item=self.get_object())),
|
||||||
|
[]
|
||||||
|
),
|
||||||
|
key=lambda r: str(r['label'])
|
||||||
|
)
|
||||||
|
ctx['extra_nav'] = nav
|
||||||
|
return ctx
|
||||||
|
|
||||||
def get_object(self, queryset=None) -> Item:
|
def get_object(self, queryset=None) -> Item:
|
||||||
try:
|
try:
|
||||||
if not hasattr(self, 'object') or not self.object:
|
if not hasattr(self, 'object') or not self.object:
|
||||||
|
|||||||
Reference in New Issue
Block a user