From 86f17094bb97c5cdb2e4a5af6c21ea8819134917 Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Mon, 31 Jul 2017 13:52:50 +0200 Subject: [PATCH] Hide quota options when creating a product with variations --- src/pretix/control/forms/item.py | 2 +- src/pretix/static/pretixcontrol/js/ui/hidequota.js | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/pretix/control/forms/item.py b/src/pretix/control/forms/item.py index a53e71af06..978e35ac60 100644 --- a/src/pretix/control/forms/item.py +++ b/src/pretix/control/forms/item.py @@ -196,7 +196,7 @@ class ItemCreateForm(I18nModelForm): instance = super().save(*args, **kwargs) - if not self.event.has_subevents: + if not self.event.has_subevents and not self.cleaned_data.get('has_variations'): 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) diff --git a/src/pretix/static/pretixcontrol/js/ui/hidequota.js b/src/pretix/static/pretixcontrol/js/ui/hidequota.js index a812b1f0b8..39326fa992 100644 --- a/src/pretix/static/pretixcontrol/js/ui/hidequota.js +++ b/src/pretix/static/pretixcontrol/js/ui/hidequota.js @@ -26,4 +26,11 @@ $(document).ready(function () { hideDeselected(true); } ); + + function toggleblock() { + $("#new-quota-group").closest('fieldset').toggle(!$("#id_has_variations").prop('checked')); + } + + $("#id_has_variations").change(toggleblock); + toggleblock(); });