mirror of
https://github.com/pretix/pretix.git
synced 2026-08-10 10:47:00 +00:00
Explicit secondary ordering of categories
This commit is contained in:
@@ -429,7 +429,7 @@ class ItemCategory(Versionable):
|
||||
class Meta:
|
||||
verbose_name = _("Item category")
|
||||
verbose_name_plural = _("Item categories")
|
||||
ordering = ('position',)
|
||||
ordering = ('position', 'id')
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
@@ -28,7 +28,8 @@ class EventIndex(EventViewMixin, 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])
|
||||
for cat in set([i.category for i in items])
|
||||
], key=lambda group: group[0].position)
|
||||
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
|
||||
return context
|
||||
|
||||
Reference in New Issue
Block a user