Add signal html_page_start

This commit is contained in:
Raphael Michel
2018-08-11 12:52:46 +02:00
parent e645a350f2
commit 693965af28
3 changed files with 31 additions and 0 deletions

View File

@@ -25,3 +25,22 @@ def eventsignal(event: Event, signame: str, **kwargs):
if response:
_html.append(response)
return mark_safe("".join(_html))
@register.simple_tag
def signal(signame: str, request, **kwargs):
"""
Send a signal and return the concatenated return values of all responses.
Usage::
{% signal request "path.to.signal" argument="value" ... %}
"""
sigstr = signame.rsplit('.', 1)
sigmod = importlib.import_module(sigstr[0])
signal = getattr(sigmod, sigstr[1])
_html = []
for receiver, response in signal.send(request, **kwargs):
if response:
_html.append(response)
return mark_safe("".join(_html))

View File

@@ -12,6 +12,16 @@ This signal is sent out to build configuration forms for all restriction formset
As with all plugin signals, the ``sender`` keyword argument will contain the event.
"""
html_page_start = Signal(
providing_args=[]
)
"""
This signal allows you to put code in the beginning of the main page for every
page in the backend. You are expected to return HTML.
The ``sender`` keyword argument will contain the request.
"""
html_head = EventPluginSignal(
providing_args=["request"]
)

View File

@@ -3,6 +3,7 @@
{% load i18n %}
{% load hijack_tags %}
{% load statici18n %}
{% load eventsignal %}
{% load eventurl %}
<!DOCTYPE html>
<html>
@@ -329,6 +330,7 @@
{% endif %}
<div id="page-wrapper">
<div class="container-fluid">
{% signal "pretix.control.signals.html_page_start" request %}
{% if messages %}
{% for message in messages %}
<div class="alert {{ message.tags }}">