diff --git a/src/pretix/control/signals.py b/src/pretix/control/signals.py index f3b68cc85..57f87109a 100644 --- a/src/pretix/control/signals.py +++ b/src/pretix/control/signals.py @@ -141,7 +141,7 @@ event_dashboard_widgets = EventPluginSignal() This signal is sent out to include widgets in the event dashboard. Receivers should return a list of dictionaries, where each dictionary can have the keys: -* content (str, containing HTML) +* content (SafeString, containing HTML) * display_size (str, one of "full" (whole row), "big" (half a row) or "small" (quarter of a row). May be ignored on small displays, default is "small") * priority (int, used for ordering, higher comes first, default is 1) @@ -158,7 +158,7 @@ Arguments: 'user' This signal is sent out to include widgets in the personal user dashboard. Receivers should return a list of dictionaries, where each dictionary can have the keys: -* content (str, containing HTML) +* content (SafeString, containing HTML) * display_size (str, one of "full" (whole row), "big" (half a row) or "small" (quarter of a row). May be ignored on small displays, default is "small") * priority (int, used for ordering, higher comes first, default is 1) diff --git a/src/pretix/control/templates/pretixcontrol/dashboard.html b/src/pretix/control/templates/pretixcontrol/dashboard.html index 7dace3937..cfc2a9046 100644 --- a/src/pretix/control/templates/pretixcontrol/dashboard.html +++ b/src/pretix/control/templates/pretixcontrol/dashboard.html @@ -28,7 +28,7 @@ {% if w.lazy %} {% else %} - {{ w.content|safe }} + {{ w.content }} {% endif %} @@ -51,7 +51,7 @@ {% if w.lazy %} {% else %} - {{ w.content|safe }} + {{ w.content }} {% endif %} @@ -72,7 +72,7 @@ {% if w.lazy %} {% else %} - {{ w.content|safe }} + {{ w.content }} {% endif %} @@ -94,7 +94,7 @@ {% if w.lazy %} {% else %} - {{ w.content|safe }} + {{ w.content }} {% endif %} {% else %} @@ -102,7 +102,7 @@ {% if w.lazy %} {% else %} - {{ w.content|safe }} + {{ w.content }} {% endif %} {% endif %} diff --git a/src/pretix/control/templates/pretixcontrol/event/index.html b/src/pretix/control/templates/pretixcontrol/event/index.html index f1fd140be..a8d04040d 100644 --- a/src/pretix/control/templates/pretixcontrol/event/index.html +++ b/src/pretix/control/templates/pretixcontrol/event/index.html @@ -106,7 +106,7 @@ {% if w.lazy %} {% else %} - {{ w.content|safe }} + {{ w.content }} {% endif %} {% elif w.link %} @@ -114,7 +114,7 @@ {% if w.lazy %} {% else %} - {{ w.content|safe }} + {{ w.content }} {% endif %} {% else %} @@ -122,7 +122,7 @@ {% if w.lazy %} {% else %} - {{ w.content|safe }} + {{ w.content }} {% endif %} {% endif %} diff --git a/src/pretix/control/views/dashboards.py b/src/pretix/control/views/dashboards.py index 02bddc996..0d8d6e6a6 100644 --- a/src/pretix/control/views/dashboards.py +++ b/src/pretix/control/views/dashboards.py @@ -49,7 +49,7 @@ from django.shortcuts import render from django.template.loader import get_template from django.urls import reverse from django.utils.formats import date_format -from django.utils.html import escape +from django.utils.html import conditional_escape, escape, format_html from django.utils.timezone import now from django.utils.translation import gettext_lazy as _, ngettext, pgettext @@ -112,7 +112,7 @@ def base_widgets(sender, subevent=None, lazy=False, **kwargs): return [ { - 'content': None if lazy else NUM_WIDGET.format(num=intcomma(tickc), text=_('Attendees (ordered)')), + 'content': None if lazy else format_html(NUM_WIDGET, num=intcomma(tickc), text=_('Attendees (ordered)')), 'lazy': 'attendees-ordered', 'display_size': 'small', 'priority': 100, @@ -122,7 +122,7 @@ def base_widgets(sender, subevent=None, lazy=False, **kwargs): }) + ('?subevent={}'.format(subevent.pk) if subevent else '') }, { - 'content': None if lazy else NUM_WIDGET.format(num=intcomma(paidc), text=_('Attendees (paid)')), + 'content': None if lazy else format_html(NUM_WIDGET, num=intcomma(paidc), text=_('Attendees (paid)')), 'lazy': 'attendees-paid', 'display_size': 'small', 'priority': 100, @@ -132,7 +132,8 @@ def base_widgets(sender, subevent=None, lazy=False, **kwargs): }) + ('?subevent={}'.format(subevent.pk) if subevent else '') }, { - 'content': None if lazy else NUM_WIDGET.format( + 'content': None if lazy else format_html( + NUM_WIDGET, num=money_filter(round_decimal(rev, sender.currency), sender.currency, hide_currency=True), text=_('Total revenue ({currency})').format(currency=sender.currency) ), @@ -145,7 +146,7 @@ def base_widgets(sender, subevent=None, lazy=False, **kwargs): }) + ('?subevent={}'.format(subevent.pk) if subevent else '') }, { - 'content': None if lazy else NUM_WIDGET.format(num=prodc, text=_('Active products')), + 'content': None if lazy else format_html(NUM_WIDGET, num=prodc, text=_('Active products')), 'lazy': 'active-products', 'display_size': 'small', 'priority': 100, @@ -209,8 +210,8 @@ def waitinglist_widgets(sender, subevent=None, lazy=False, **kwargs): quota_cache[q.pk] = (quota_cache[q.pk][0], quota_cache[q.pk][1] - min(wlt['cnt'], row[1])) widgets.append({ - 'content': None if lazy else NUM_WIDGET.format( - num=intcomma(happy), text=_('available to give to people on waiting list') + 'content': None if lazy else format_html( + NUM_WIDGET, num=intcomma(happy), text=_('available to give to people on waiting list') ), 'lazy': 'waitinglist-avail', 'priority': 50, @@ -220,7 +221,9 @@ def waitinglist_widgets(sender, subevent=None, lazy=False, **kwargs): }) }) widgets.append({ - 'content': None if lazy else NUM_WIDGET.format(num=intcomma(wles.count()), text=_('total waiting list length')), + 'content': None if lazy else format_html( + NUM_WIDGET, num=intcomma(wles.count()), text=_('total waiting list length') + ), 'lazy': 'waitinglist-length', 'display_size': 'small', 'priority': 50, @@ -247,7 +250,8 @@ def quota_widgets(sender, subevent=None, lazy=False, **kwargs): if not lazy: status, left = qa.results[q] if q in qa.results else q.availability(allow_cache=True) widgets.append({ - 'content': None if lazy else NUM_WIDGET.format( + 'content': None if lazy else format_html( + NUM_WIDGET, num='{}/{}'.format(intcomma(left), intcomma(q.size)) if q.size is not None else '\u221e', text=_('{quota} left').format(quota=escape(q.name)) ), @@ -268,7 +272,8 @@ def shop_state_widget(sender, **kwargs): return [{ 'display_size': 'small', 'priority': 1000, - 'content': '