From 35a9ab8f62725debc580b6a94dc429a550c34952 Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Sun, 3 Jul 2016 16:49:56 +0200 Subject: [PATCH] Added signals that allow to modify the voucher form --- doc/development/api/general.rst | 3 +++ src/pretix/control/signals.py | 21 +++++++++++++++++++ .../pretixcontrol/vouchers/detail.html | 2 ++ src/pretix/control/views/vouchers.py | 17 +++++++++++++-- 4 files changed, 41 insertions(+), 2 deletions(-) diff --git a/doc/development/api/general.rst b/doc/development/api/general.rst index 9a1a43b3f6..88c93e6f47 100644 --- a/doc/development/api/general.rst +++ b/doc/development/api/general.rst @@ -43,6 +43,9 @@ Voucher system .. automodule:: pretix.presale.signals :members: voucher_redeem_info +.. automodule:: pretix.control.signals + :members: voucher_form_class, voucher_form_html + Dashboards ---------- diff --git a/src/pretix/control/signals.py b/src/pretix/control/signals.py index 6de3688849..9dae91c68d 100644 --- a/src/pretix/control/signals.py +++ b/src/pretix/control/signals.py @@ -73,3 +73,24 @@ should return a list of dictionaries, where each dictionary can have the keys: This is a regular django signal (no pretix event signal). """ + +voucher_form_html = EventPluginSignal( + providing_args=['form'] +) +""" +This signal allows you to add additional HTML to the form that is used for modifying vouchers. +You receive the form object in the ``form`` keyword argument. + +As with all plugin signals, the ``sender`` keyword argument will contain the event. +""" + +voucher_form_class = EventPluginSignal( + providing_args=['cls'] +) +""" +This signal allows you to replace the form class that is used for modifying vouchers. +You will receive the default form class (or the class set by a previous plugin) in the +``cls`` argument such that you can inherit from it. + +As with all plugin signals, the ``sender`` keyword argument will contain the event. +""" diff --git a/src/pretix/control/templates/pretixcontrol/vouchers/detail.html b/src/pretix/control/templates/pretixcontrol/vouchers/detail.html index f3ebf569c2..3a5367eb5f 100644 --- a/src/pretix/control/templates/pretixcontrol/vouchers/detail.html +++ b/src/pretix/control/templates/pretixcontrol/vouchers/detail.html @@ -1,6 +1,7 @@ {% extends "pretixcontrol/items/base.html" %} {% load i18n %} {% load bootstrap3 %} +{% load eventsignal %} {% block title %}{% trans "Voucher" %}{% endblock %} {% block inside %}

{% trans "Voucher" %}

@@ -36,6 +37,7 @@ {% bootstrap_field form.tag layout="horizontal" %} {% bootstrap_field form.comment layout="horizontal" %} + {% eventsignal request.event "pretix.control.signals.voucher_form_html" form=form %}