fix iteration

This commit is contained in:
Mira Weller
2024-10-09 11:58:36 +02:00
parent 9a6756ce5d
commit a314d219b8
2 changed files with 6 additions and 6 deletions

View File

@@ -54,22 +54,22 @@ class CrossSellingService:
def get_data(self):
if self.event.has_subevents:
subevents = set(pos.subevent for pos in self.cartpositions)
result = (
result = [
(DummyCategory(category, subevent),
self._prepare_items(subevent, items_qs, discount_info),
f'subevent_{subevent.pk}_')
for subevent in subevents
for (category, items_qs, discount_info) in self._applicable_categories(subevent.pk)
)
]
else:
result = (
result = [
(category,
self._prepare_items(None, items_qs, discount_info),
'')
for (category, items_qs, discount_info) in self._applicable_categories(0)
)
]
for category, items, form_prefix in result:
category.has_discount = any(item.original_price for item in items)
category.category_has_discount = any(item.original_price for item in items)
return [(category, items, form_prefix) for (category, items, form_prefix) in result if len(items) > 0]
def _applicable_categories(self, subevent_id):

View File

@@ -9,7 +9,7 @@
{% if category %}
<section aria-labelledby="{{ form_prefix }}category-{{ category.id }}"{% if category.description %} aria-describedby="{{ form_prefix }}category-info-{{ category.id }}"{% endif %}>
<h3 id="{{ form_prefix }}category-{{ category.id }}">{{ category.name }}
{% if category.has_discount %}
{% if category.category_has_discount %}
<small class="text-success"><i class="fa fa-star"></i> {% trans "Your order qualifies for a discount" %}</small>
{% endif %}
</h3>