forked from CGM_Public/pretix_original
Deal with items that belong to no category
This commit is contained in:
@@ -35,7 +35,7 @@
|
||||
{% csrf_token %}
|
||||
{% for tup in items_by_category %}
|
||||
<section>
|
||||
<h3>{{ tup.0.name }}</h3>
|
||||
{% if tup.0 %}<h3>{{ tup.0.name }}</h3>{% endif %}
|
||||
{% for item in tup.1 %}
|
||||
{% if item.has_variations %}
|
||||
<div class="row-fluid product-row headline">
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
@@ -49,9 +49,10 @@ class EventIndex(EventViewMixin, CartDisplayMixin, TemplateView):
|
||||
# Regroup those by category
|
||||
context['items_by_category'] = sorted([
|
||||
# a group is a tuple of a category and a list of items
|
||||
(cat, [i for i in items if i.category_id == cat.identity])
|
||||
(cat, [i for i in items if i.category == cat])
|
||||
for cat in set([i.category for i in items]) # insert categories into a set for uniqueness
|
||||
], key=lambda group: (group[0].position, group[0].pk)) # a set is unsorted, so sort again by category
|
||||
# a set is unsorted, so sort again by category
|
||||
], key=lambda group: (group[0].position, group[0].identity) if group[0] is not None else (0, ""))
|
||||
|
||||
context['cart'] = self.get_cart() if self.request.user.is_authenticated() else None
|
||||
return context
|
||||
|
||||
Reference in New Issue
Block a user