forked from CGM_Public/pretix_original
Hide quota options during product creation for event series
This commit is contained in:
@@ -145,6 +145,7 @@ class ItemCreateForm(I18nModelForm):
|
||||
required=False
|
||||
)
|
||||
|
||||
if not self.event.has_subevents:
|
||||
self.fields['quota_option'] = forms.ChoiceField(
|
||||
label=_("Quota options"),
|
||||
widget=forms.RadioSelect,
|
||||
@@ -194,6 +195,7 @@ class ItemCreateForm(I18nModelForm):
|
||||
|
||||
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:
|
||||
quota = self.cleaned_data.get('quota_add_existing')
|
||||
quota.items.add(self.instance)
|
||||
@@ -225,6 +227,7 @@ class ItemCreateForm(I18nModelForm):
|
||||
def clean(self):
|
||||
cleaned_data = super().clean()
|
||||
|
||||
if not self.event.has_subevents:
|
||||
if cleaned_data.get('quota_option') == self.NEW:
|
||||
if not self.cleaned_data.get('quota_add_new_name'):
|
||||
raise forms.ValidationError(
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
{% bootstrap_field form.category layout="horizontal" %}
|
||||
{% bootstrap_field form.admission layout="horizontal" %}
|
||||
</fieldset>
|
||||
{% if form.quota_option %}
|
||||
<fieldset>
|
||||
<legend>{% trans "Quota settings" %}</legend>
|
||||
{% bootstrap_field form.quota_option layout="horizontal" %}
|
||||
@@ -26,6 +27,7 @@
|
||||
{% bootstrap_field form.quota_add_new_size layout="horizontal" %}
|
||||
</div>
|
||||
</fieldset>
|
||||
{% endif %}
|
||||
<fieldset>
|
||||
<legend>{% trans "Price settings" %}</legend>
|
||||
{% bootstrap_field form.default_price layout="horizontal" %}
|
||||
|
||||
Reference in New Issue
Block a user