From 0b02bcea8b9bb2ba1fffd4ec93051491eeff7bbc Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Sun, 19 Apr 2020 14:17:41 +0200 Subject: [PATCH] Prevent cancelling all subevents by accident --- src/pretix/control/forms/orders.py | 12 ++++++++++++ .../templates/pretixcontrol/orders/cancel.html | 1 + 2 files changed, 13 insertions(+) diff --git a/src/pretix/control/forms/orders.py b/src/pretix/control/forms/orders.py index 63e15480c7..9b5a205701 100644 --- a/src/pretix/control/forms/orders.py +++ b/src/pretix/control/forms/orders.py @@ -540,6 +540,11 @@ class EventCancelForm(forms.Form): required=False, empty_label=pgettext_lazy('subevent', 'All dates') ) + all_subevents = forms.BooleanField( + label=_('Cancel all dates'), + initial=False, + required=False + ) auto_refund = forms.BooleanField( label=_('Automatically refund money if possible'), initial=True, @@ -678,4 +683,11 @@ class EventCancelForm(forms.Form): self.fields['subevent'].widget.choices = self.fields['subevent'].choices else: del self.fields['subevent'] + del self.fields['all_subevents'] change_decimal_field(self.fields['keep_fee_fixed'], self.event.currency) + + def clean(self): + d = super().clean() + if self.event.has_subevents and not d['subevent'] and not d['all_subevents']: + raise ValidationError(_('Please confirm that you want to cancel ALL dates in this event series.')) + return d diff --git a/src/pretix/control/templates/pretixcontrol/orders/cancel.html b/src/pretix/control/templates/pretixcontrol/orders/cancel.html index 9d9877f503..dcf9681fa9 100644 --- a/src/pretix/control/templates/pretixcontrol/orders/cancel.html +++ b/src/pretix/control/templates/pretixcontrol/orders/cancel.html @@ -28,6 +28,7 @@
{% trans "Select date" context "subevents" %} {% bootstrap_field form.subevent layout="control" %} + {% bootstrap_field form.all_subevents layout="control" %}
{% endif %}