From 194042dca5d44e03090a1a01783dbf1662068f64 Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Wed, 26 Jan 2022 09:45:26 +0100 Subject: [PATCH] Add-on selection: Fix incorrect pre-selection across multiple base positions --- src/pretix/presale/checkoutflow.py | 6 +++++- .../pretixpresale/event/order_change_confirm.html | 8 ++++---- src/pretix/presale/views/order.py | 8 ++++++-- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/pretix/presale/checkoutflow.py b/src/pretix/presale/checkoutflow.py index 6e97914d1d..9584520f7e 100644 --- a/src/pretix/presale/checkoutflow.py +++ b/src/pretix/presale/checkoutflow.py @@ -513,7 +513,11 @@ class AddOnsStep(CartMixin, AsyncAction, TemplateFlowStep): ) item_cache[ckey] = items else: - items = item_cache[ckey] + # We can use the cache to prevent a database fetch, but we need separate Python objects + # or our things below like setting `i.initial` will do the wrong thing. + items = [copy.copy(i) for i in item_cache[ckey]] + for i in items: + i.available_variations = [copy.copy(v) for v in i.available_variations] for i in items: i.allow_waitinglist = False diff --git a/src/pretix/presale/templates/pretixpresale/event/order_change_confirm.html b/src/pretix/presale/templates/pretixpresale/event/order_change_confirm.html index 8259134cc4..169b80e85d 100644 --- a/src/pretix/presale/templates/pretixpresale/event/order_change_confirm.html +++ b/src/pretix/presale/templates/pretixpresale/event/order_change_confirm.html @@ -82,12 +82,12 @@ {% if op.variation %} - {% blocktrans trimmed with positionid=op.position.positionid item=op.item.name variation=op.variation.value %} - Add position #{{ positionid }} ({{ item }} – {{ variation }}) + {% blocktrans trimmed with item=op.item.name variation=op.variation.value %} + Add position ({{ item }} – {{ variation }}) {% endblocktrans %} {% else %} - {% blocktrans trimmed with positionid=op.position.positionid item=op.item.name %} - Add position #{{ positionid }} ({{ item }}) + {% blocktrans trimmed with item=op.item.name %} + Add position ({{ item }}) {% endblocktrans %} {% endif %} {% if op.addon_to %} diff --git a/src/pretix/presale/views/order.py b/src/pretix/presale/views/order.py index eb6b828507..0f222c975a 100644 --- a/src/pretix/presale/views/order.py +++ b/src/pretix/presale/views/order.py @@ -32,7 +32,7 @@ # Unless required by applicable law or agreed to in writing, software distributed under the Apache License 2.0 is # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations under the License. - +import copy import inspect import json import mimetypes @@ -1242,7 +1242,11 @@ class OrderChange(EventViewMixin, OrderDetailMixin, TemplateView): ) item_cache[ckey] = items else: - items = item_cache[ckey] + # We can use the cache to prevent a database fetch, but we need separate Python objects + # or our things below like setting `i.initial` will do the wrong thing. + items = [copy.copy(i) for i in item_cache[ckey]] + for i in items: + i.available_variations = [copy.copy(v) for v in i.available_variations] for i in items: i.allow_waitinglist = False