Prevent cancelling all subevents by accident

This commit is contained in:
Raphael Michel
2020-04-19 14:17:41 +02:00
parent 1d8668aaf1
commit 0b02bcea8b
2 changed files with 13 additions and 0 deletions

View File

@@ -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

View File

@@ -28,6 +28,7 @@
<fieldset>
<legend>{% trans "Select date" context "subevents" %}</legend>
{% bootstrap_field form.subevent layout="control" %}
{% bootstrap_field form.all_subevents layout="control" %}
</fieldset>
{% endif %}
<fieldset>