Add-on selection: Fix incorrect pre-selection across multiple base positions

This commit is contained in:
Raphael Michel
2022-01-26 09:45:26 +01:00
parent 3be6e83f33
commit 194042dca5
3 changed files with 15 additions and 7 deletions

View File

@@ -513,7 +513,11 @@ class AddOnsStep(CartMixin, AsyncAction, TemplateFlowStep):
) )
item_cache[ckey] = items item_cache[ckey] = items
else: 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: for i in items:
i.allow_waitinglist = False i.allow_waitinglist = False

View File

@@ -82,12 +82,12 @@
<tr> <tr>
<td> <td>
{% if op.variation %} {% if op.variation %}
{% blocktrans trimmed with positionid=op.position.positionid item=op.item.name variation=op.variation.value %} {% blocktrans trimmed with item=op.item.name variation=op.variation.value %}
Add position #{{ positionid }} ({{ item }} {{ variation }}) Add position ({{ item }} {{ variation }})
{% endblocktrans %} {% endblocktrans %}
{% else %} {% else %}
{% blocktrans trimmed with positionid=op.position.positionid item=op.item.name %} {% blocktrans trimmed with item=op.item.name %}
Add position #{{ positionid }} ({{ item }}) Add position ({{ item }})
{% endblocktrans %} {% endblocktrans %}
{% endif %} {% endif %}
{% if op.addon_to %} {% if op.addon_to %}

View File

@@ -32,7 +32,7 @@
# Unless required by applicable law or agreed to in writing, software distributed under the Apache License 2.0 is # 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 # 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. # License for the specific language governing permissions and limitations under the License.
import copy
import inspect import inspect
import json import json
import mimetypes import mimetypes
@@ -1242,7 +1242,11 @@ class OrderChange(EventViewMixin, OrderDetailMixin, TemplateView):
) )
item_cache[ckey] = items item_cache[ckey] = items
else: 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: for i in items:
i.allow_waitinglist = False i.allow_waitinglist = False