Skip to content
Snippets Groups Projects
Commit 185debcb authored by Benjamin Hättasch's avatar Benjamin Hättasch
Browse files

Fix categories for submission overview

This fix ensures that the categories in submission overview are shown even when there is no AK with this category submitted yet.
parent 6b123649
No related branches found
No related tags found
1 merge request!21Fix categories for submission overview
......@@ -70,7 +70,7 @@
</noscript>
<ul class="nav nav-tabs" style="margin-bottom:15px">
{% for category, _ in categories %}
{% for category, _ in categories_with_aks %}
<li class="nav-item">
<a class="nav-link {% if forloop.first %}active{% endif %}" data-toggle="tab"
href="#category_{{ category.pk }}">{{ category.name }}</a>
......@@ -79,7 +79,7 @@
</ul>
<div id="akListTabbed" class="tab-content">
{% for category, AKs in categories %}
{% for category, AKs in categories_with_aks %}
<div class="tab-pane fade {% if forloop.first %}show active{% endif %}" id="category_{{ category.pk }}">
<p><b>{{ category.name }}:</b> {{ category.description }}</p>
{% include "AKSubmission/ak_list_table.html" %}
......
......@@ -14,33 +14,30 @@ from AKSubmission.forms import AKWishForm, AKOwnerForm, AKEditForm, AKSubmission
class SubmissionOverviewView(FilterByEventSlugMixin, ListView):
model = AK
context_object_name = "AKs"
model = AKCategory
context_object_name = "categories"
template_name = "AKSubmission/submission_overview.html"
ordering = ['category']
def get_context_data(self, *, object_list=None, **kwargs):
context = super().get_context_data(object_list=object_list, **kwargs)
# Sort AKs into different lists (by their category)
categories = []
aks_for_category = []
ak_wishes = []
current_category = None
for ak in context["AKs"]:
if ak.category != current_category:
current_category = ak.category
aks_for_category = []
categories.append((current_category, aks_for_category))
if settings.WISHES_AS_CATEGORY and ak.wish:
ak_wishes.append(ak)
else:
aks_for_category.append(ak)
categories_with_aks = []
for category in context["categories"]:
aks_for_category = []
for ak in category.ak_set.all():
if settings.WISHES_AS_CATEGORY and ak.wish:
ak_wishes.append(ak)
else:
aks_for_category.append(ak)
categories_with_aks.append((category, aks_for_category))
if settings.WISHES_AS_CATEGORY:
categories.append(
categories_with_aks.append(
({"name": _("Wishes"), "pk": "wish", "description": _("AKs one would like to have")}, ak_wishes))
context["categories"] = categories
context["categories_with_aks"] = categories_with_aks
# Get list of existing owners for event (for AK submission start)
context["existingOwners"] = AKOwner.objects.filter(event=self.event)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment