Hide quota options during product creation for event series

This commit is contained in:
Raphael Michel
2017-07-27 15:14:28 +02:00
parent 5c443e2f93
commit f43d782b5c
2 changed files with 66 additions and 61 deletions

View File

@@ -145,6 +145,7 @@ class ItemCreateForm(I18nModelForm):
required=False required=False
) )
if not self.event.has_subevents:
self.fields['quota_option'] = forms.ChoiceField( self.fields['quota_option'] = forms.ChoiceField(
label=_("Quota options"), label=_("Quota options"),
widget=forms.RadioSelect, widget=forms.RadioSelect,
@@ -194,6 +195,7 @@ class ItemCreateForm(I18nModelForm):
instance = super().save(*args, **kwargs) instance = super().save(*args, **kwargs)
if not self.event.has_subevents:
if self.cleaned_data.get('quota_option') == self.EXISTING and self.cleaned_data.get('quota_add_existing') is not None: if self.cleaned_data.get('quota_option') == self.EXISTING and self.cleaned_data.get('quota_add_existing') is not None:
quota = self.cleaned_data.get('quota_add_existing') quota = self.cleaned_data.get('quota_add_existing')
quota.items.add(self.instance) quota.items.add(self.instance)
@@ -225,6 +227,7 @@ class ItemCreateForm(I18nModelForm):
def clean(self): def clean(self):
cleaned_data = super().clean() cleaned_data = super().clean()
if not self.event.has_subevents:
if cleaned_data.get('quota_option') == self.NEW: if cleaned_data.get('quota_option') == self.NEW:
if not self.cleaned_data.get('quota_add_new_name'): if not self.cleaned_data.get('quota_add_new_name'):
raise forms.ValidationError( raise forms.ValidationError(

View File

@@ -15,6 +15,7 @@
{% bootstrap_field form.category layout="horizontal" %} {% bootstrap_field form.category layout="horizontal" %}
{% bootstrap_field form.admission layout="horizontal" %} {% bootstrap_field form.admission layout="horizontal" %}
</fieldset> </fieldset>
{% if form.quota_option %}
<fieldset> <fieldset>
<legend>{% trans "Quota settings" %}</legend> <legend>{% trans "Quota settings" %}</legend>
{% bootstrap_field form.quota_option layout="horizontal" %} {% bootstrap_field form.quota_option layout="horizontal" %}
@@ -26,6 +27,7 @@
{% bootstrap_field form.quota_add_new_size layout="horizontal" %} {% bootstrap_field form.quota_add_new_size layout="horizontal" %}
</div> </div>
</fieldset> </fieldset>
{% endif %}
<fieldset> <fieldset>
<legend>{% trans "Price settings" %}</legend> <legend>{% trans "Price settings" %}</legend>
{% bootstrap_field form.default_price layout="horizontal" %} {% bootstrap_field form.default_price layout="horizontal" %}