diff --git a/src/pretix/control/forms/item.py b/src/pretix/control/forms/item.py index 76b1d25472..d27c00b468 100644 --- a/src/pretix/control/forms/item.py +++ b/src/pretix/control/forms/item.py @@ -97,7 +97,32 @@ class QuotaForm(I18nModelForm): ] -class ItemFormGeneral(I18nModelForm): +class ItemCreateForm(I18nModelForm): + has_variations = forms.BooleanField(label=_('The product should exist in multiple variations'), + help_text=_('Select this option e.g. for t-shirts that come in multiple sizes. ' + 'You can select the variations in the next step.'), + required=False) + + def save(self, *args, **kwargs): + instance = super().save(*args, **kwargs) + if self.cleaned_data.get('has_variations'): + ItemVariation.objects.create( + item=instance, value=__('Standard') + ) + return instance + + class Meta: + model = Item + localized_fields = '__all__' + fields = [ + 'name', + 'admission', + 'default_price', + 'tax_rate', + ] + + +class ItemUpdateForm(I18nModelForm): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.fields['category'].queryset = self.instance.event.categories.all() @@ -120,21 +145,6 @@ class ItemFormGeneral(I18nModelForm): ] -class ItemCreateForm(ItemFormGeneral): - has_variations = forms.BooleanField(label=_('The product should exist in multiple variations'), - help_text=_('Select this option e.g. for t-shirts that come in multiple sizes. ' - 'You can select the variations in the next step.'), - required=False) - - def save(self, *args, **kwargs): - instance = super().save(*args, **kwargs) - if self.cleaned_data.get('has_variations'): - ItemVariation.objects.create( - item=instance, value=__('Standard') - ) - return instance - - class ItemVariationForm(I18nModelForm): class Meta: model = ItemVariation diff --git a/src/pretix/control/templates/pretixcontrol/item/create.html b/src/pretix/control/templates/pretixcontrol/item/create.html new file mode 100644 index 0000000000..2eeb17a995 --- /dev/null +++ b/src/pretix/control/templates/pretixcontrol/item/create.html @@ -0,0 +1,24 @@ +{% extends "pretixcontrol/item/base.html" %} +{% load i18n %} +{% load bootstrap3 %} +{% block inside %} +
+{% endblock %} diff --git a/src/pretix/control/templates/pretixcontrol/item/index.html b/src/pretix/control/templates/pretixcontrol/item/index.html index 72aecb79e3..470abc4ce8 100644 --- a/src/pretix/control/templates/pretixcontrol/item/index.html +++ b/src/pretix/control/templates/pretixcontrol/item/index.html @@ -8,9 +8,6 @@ {% bootstrap_field form.name layout="horizontal" %} {% bootstrap_field form.active layout="horizontal" %} - {% if form.has_variations %} - {% bootstrap_field form.has_variations layout="horizontal" %} - {% endif %} {% bootstrap_field form.category layout="horizontal" %} {% bootstrap_field form.admission layout="horizontal" %} {% bootstrap_field form.description layout="horizontal" %} diff --git a/src/pretix/control/views/item.py b/src/pretix/control/views/item.py index fdac421e00..6c06bd1916 100644 --- a/src/pretix/control/views/item.py +++ b/src/pretix/control/views/item.py @@ -17,7 +17,7 @@ from pretix.base.models import ( Item, ItemCategory, ItemVariation, Question, QuestionOption, Quota, ) from pretix.control.forms.item import ( - CategoryForm, ItemCreateForm, ItemFormGeneral, ItemVariationForm, + CategoryForm, ItemCreateForm, ItemUpdateForm, ItemVariationForm, QuestionForm, QuestionOptionForm, QuotaForm, ) from pretix.control.permissions import ( @@ -568,7 +568,7 @@ class ItemDetailMixin(SingleObjectMixin): class ItemCreate(EventPermissionRequiredMixin, CreateView): form_class = ItemCreateForm - template_name = 'pretixcontrol/item/index.html' + template_name = 'pretixcontrol/item/create.html' permission = 'can_change_items' def get_success_url(self) -> str: @@ -601,7 +601,7 @@ class ItemCreate(EventPermissionRequiredMixin, CreateView): class ItemUpdateGeneral(ItemDetailMixin, EventPermissionRequiredMixin, UpdateView): - form_class = ItemFormGeneral + form_class = ItemUpdateForm template_name = 'pretixcontrol/item/index.html' permission = 'can_change_items'