diff --git a/doc/development/api/general.rst b/doc/development/api/general.rst index 37d6ed2248..75bef4474f 100644 --- a/doc/development/api/general.rst +++ b/doc/development/api/general.rst @@ -83,7 +83,7 @@ Dashboards .. automodule:: pretix.control.signals :no-index: - :members: event_dashboard_widgets, user_dashboard_widgets, event_dashboard_top + :members: event_dashboard_widgets, event_dashboard_widgets_override, user_dashboard_widgets, event_dashboard_top Ticket designs """""""""""""" diff --git a/src/pretix/control/signals.py b/src/pretix/control/signals.py index 57f87109a0..183542675b 100644 --- a/src/pretix/control/signals.py +++ b/src/pretix/control/signals.py @@ -149,6 +149,31 @@ should return a list of dictionaries, where each dictionary can have the keys: As with all event plugin signals, the ``sender`` keyword argument will contain the event. An additional keyword argument ``subevent`` *can* contain a sub-event. + +The keyword argument ``widgets_override_active`` is set to ``True`` when a plugin +has returned content from :py:data:`event_dashboard_widgets_override` and is taking +over the KPI section of the dashboard. Receivers that produce widgets which would +be redundant with such a replacement (e.g. the built-in attendees/revenue/products +KPI tiles) should return an empty list in that case. Receivers that provide widgets +unrelated to the KPI tiles (waitinglist, quotas, check-in lists, shop state, etc.) +should ignore the flag and continue to return their widgets — those will render +below the override block. +""" + +event_dashboard_widgets_override = EventPluginSignal() +""" +This signal allows a plugin to take over the KPI section of the event dashboard +with custom HTML. Receivers should return an HTML string (or an empty string / +``None`` to opt out). If any receiver returns non-empty HTML, that HTML is +rendered at the top of the dashboard, and receivers of +:py:data:`event_dashboard_widgets` are informed via the +``widgets_override_active=True`` keyword argument so they can suppress widgets +that the override replaces. The remaining widgets (those that don't opt out) +still render below the override block. Multiple receivers' return values are +concatenated. + +As with all event plugin signals, the ``sender`` keyword argument will contain +the event. An additional keyword argument ``subevent`` *can* contain a sub-event. """ user_dashboard_widgets = GlobalSignal() diff --git a/src/pretix/control/templates/pretixcontrol/event/index.html b/src/pretix/control/templates/pretixcontrol/event/index.html index 42941b2349..797d939e48 100644 --- a/src/pretix/control/templates/pretixcontrol/event/index.html +++ b/src/pretix/control/templates/pretixcontrol/event/index.html @@ -43,37 +43,42 @@ {% if not request.event.has_subevents or subevent %} {% include "pretixcontrol/event/fragment_timeline.html" %} {% endif %} -
- {% for w in widgets %} -
- {% if w.url %}{# backwards compatibility #} - - {% if w.lazy %} - - {% else %} - {{ w.content }} - {% endif %} - - {% elif w.link %} - - {% if w.lazy %} - - {% else %} - {{ w.content }} - {% endif %} - - {% else %} -
- {% if w.lazy %} - - {% else %} - {{ w.content }} - {% endif %} -
- {% endif %} -
- {% endfor %} -
+ {% if widgets_override %} + {{ widgets_override|safe }} + {% endif %} + {% if widgets %} +
+ {% for w in widgets %} +
+ {% if w.url %}{# backwards compatibility #} + + {% if w.lazy %} + + {% else %} + {{ w.content }} + {% endif %} + + {% elif w.link %} + + {% if w.lazy %} + + {% else %} + {{ w.content }} + {% endif %} + + {% else %} +
+ {% if w.lazy %} + + {% else %} + {{ w.content }} + {% endif %} +
+ {% endif %} +
+ {% endfor %} +
+ {% endif %}

 

diff --git a/src/pretix/control/views/dashboards.py b/src/pretix/control/views/dashboards.py index cfa98a5622..54a6f1b9df 100644 --- a/src/pretix/control/views/dashboards.py +++ b/src/pretix/control/views/dashboards.py @@ -61,7 +61,8 @@ from pretix.base.models import ( from pretix.base.services.quotas import QuotaAvailability from pretix.base.timeline import timeline_for_event from pretix.control.signals import ( - event_dashboard_widgets, user_dashboard_widgets, + event_dashboard_widgets, event_dashboard_widgets_override, + user_dashboard_widgets, ) from pretix.helpers.daterange import daterange @@ -74,7 +75,9 @@ NUM_WIDGET = '
{num}