Add new signal voucher_form_validation

This commit is contained in:
Raphael Michel
2017-08-10 17:03:05 +02:00
parent e31bd7600c
commit 57143a434e
3 changed files with 15 additions and 1 deletions

View File

@@ -8,6 +8,7 @@ from django.utils.translation import pgettext_lazy, ugettext_lazy as _
from pretix.base.forms import I18nModelForm
from pretix.base.models import Item, ItemVariation, Quota, Voucher
from pretix.control.signals import voucher_form_validation
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():
raise ValidationError(_('A voucher with this code already exists.'))
voucher_form_validation.send(sender=self.instance.event, form=self, data=data)
return data
def _clean_quota_needs_checking(self, data):