forked from CGM_Public/pretix_original
Add new signal voucher_form_validation
This commit is contained in:
@@ -57,7 +57,7 @@ Vouchers
|
|||||||
""""""""
|
""""""""
|
||||||
|
|
||||||
.. automodule:: pretix.control.signals
|
.. automodule:: pretix.control.signals
|
||||||
:members: voucher_form_class, voucher_form_html
|
:members: voucher_form_class, voucher_form_html, voucher_form_validation
|
||||||
|
|
||||||
Dashboards
|
Dashboards
|
||||||
""""""""""
|
""""""""""
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ from django.utils.translation import pgettext_lazy, ugettext_lazy as _
|
|||||||
|
|
||||||
from pretix.base.forms import I18nModelForm
|
from pretix.base.forms import I18nModelForm
|
||||||
from pretix.base.models import Item, ItemVariation, Quota, Voucher
|
from pretix.base.models import Item, ItemVariation, Quota, Voucher
|
||||||
|
from pretix.control.signals import voucher_form_validation
|
||||||
|
|
||||||
|
|
||||||
class VoucherForm(I18nModelForm):
|
class VoucherForm(I18nModelForm):
|
||||||
@@ -121,6 +122,8 @@ class VoucherForm(I18nModelForm):
|
|||||||
if 'code' in data and Voucher.objects.filter(Q(code=data['code']) & Q(event=self.instance.event) & ~Q(pk=self.instance.pk)).exists():
|
if 'code' in data and Voucher.objects.filter(Q(code=data['code']) & Q(event=self.instance.event) & ~Q(pk=self.instance.pk)).exists():
|
||||||
raise ValidationError(_('A voucher with this code already exists.'))
|
raise ValidationError(_('A voucher with this code already exists.'))
|
||||||
|
|
||||||
|
voucher_form_validation.send(sender=self.instance.event, form=self, data=data)
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def _clean_quota_needs_checking(self, data):
|
def _clean_quota_needs_checking(self, data):
|
||||||
|
|||||||
@@ -133,6 +133,17 @@ You will receive the default form class (or the class set by a previous plugin)
|
|||||||
As with all plugin signals, the ``sender`` keyword argument will contain the event.
|
As with all plugin signals, the ``sender`` keyword argument will contain the event.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
voucher_form_validation = EventPluginSignal(
|
||||||
|
providing_args=['form']
|
||||||
|
)
|
||||||
|
"""
|
||||||
|
This signal allows you to add additional validation to the form that is used for
|
||||||
|
creating and modifying vouchers. You will receive the form instance in the ``form``
|
||||||
|
argument and the current data state in the ``data`` argument.
|
||||||
|
|
||||||
|
As with all plugin signals, the ``sender`` keyword argument will contain the event.
|
||||||
|
"""
|
||||||
|
|
||||||
quota_detail_html = EventPluginSignal(
|
quota_detail_html = EventPluginSignal(
|
||||||
providing_args=['quota']
|
providing_args=['quota']
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user