mirror of
https://github.com/pretix/pretix.git
synced 2026-05-15 16:54:00 +00:00
Order change form: Allow to add multiple identical positions (Z#23227479)
This commit is contained in:
@@ -331,6 +331,10 @@ class OtherOperationsForm(forms.Form):
|
|||||||
|
|
||||||
|
|
||||||
class OrderPositionAddForm(forms.Form):
|
class OrderPositionAddForm(forms.Form):
|
||||||
|
count = forms.IntegerField(
|
||||||
|
label=_('Number of products to add'),
|
||||||
|
initial=1,
|
||||||
|
)
|
||||||
itemvar = forms.ChoiceField(
|
itemvar = forms.ChoiceField(
|
||||||
label=_('Product')
|
label=_('Product')
|
||||||
)
|
)
|
||||||
@@ -432,6 +436,10 @@ class OrderPositionAddForm(forms.Form):
|
|||||||
d['used_membership'] = [m for m in self.memberships if str(m.pk) == d['used_membership']][0]
|
d['used_membership'] = [m for m in self.memberships if str(m.pk) == d['used_membership']][0]
|
||||||
else:
|
else:
|
||||||
d['used_membership'] = None
|
d['used_membership'] = None
|
||||||
|
if d.get("count", 1) and d.get("seat"):
|
||||||
|
raise ValidationError({
|
||||||
|
"seat": _("You can not choose a seat when adding multiple products at once.")
|
||||||
|
})
|
||||||
return d
|
return d
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -329,6 +329,7 @@
|
|||||||
{{ add_form.custom_error }}
|
{{ add_form.custom_error }}
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% bootstrap_field add_form.count layout="control" %}
|
||||||
{% bootstrap_field add_form.itemvar layout="control" %}
|
{% bootstrap_field add_form.itemvar layout="control" %}
|
||||||
{% bootstrap_field add_form.price addon_after=request.event.currency layout="control" %}
|
{% bootstrap_field add_form.price addon_after=request.event.currency layout="control" %}
|
||||||
{% if add_form.addon_to %}
|
{% if add_form.addon_to %}
|
||||||
@@ -364,6 +365,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<div class="form-horizontal">
|
<div class="form-horizontal">
|
||||||
|
{% bootstrap_field add_position_formset.empty_form.count layout="control" %}
|
||||||
{% bootstrap_field add_position_formset.empty_form.itemvar layout="control" %}
|
{% bootstrap_field add_position_formset.empty_form.itemvar layout="control" %}
|
||||||
{% bootstrap_field add_position_formset.empty_form.price addon_after=request.event.currency layout="control" %}
|
{% bootstrap_field add_position_formset.empty_form.price addon_after=request.event.currency layout="control" %}
|
||||||
{% if add_position_formset.empty_form.addon_to %}
|
{% if add_position_formset.empty_form.addon_to %}
|
||||||
|
|||||||
@@ -2059,12 +2059,13 @@ class OrderChange(OrderView):
|
|||||||
else:
|
else:
|
||||||
variation = None
|
variation = None
|
||||||
try:
|
try:
|
||||||
ocm.add_position(item, variation,
|
for i in range(f.cleaned_data.get("count", 1)):
|
||||||
f.cleaned_data['price'],
|
ocm.add_position(item, variation,
|
||||||
f.cleaned_data.get('addon_to'),
|
f.cleaned_data['price'],
|
||||||
f.cleaned_data.get('subevent'),
|
f.cleaned_data.get('addon_to'),
|
||||||
f.cleaned_data.get('seat'),
|
f.cleaned_data.get('subevent'),
|
||||||
f.cleaned_data.get('used_membership'))
|
f.cleaned_data.get('seat'),
|
||||||
|
f.cleaned_data.get('used_membership'))
|
||||||
except OrderError as e:
|
except OrderError as e:
|
||||||
f.custom_error = str(e)
|
f.custom_error = str(e)
|
||||||
return False
|
return False
|
||||||
|
|||||||
Reference in New Issue
Block a user