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
No related merge requests found
...@@ -70,7 +70,7 @@ ...@@ -70,7 +70,7 @@
</noscript> </noscript>
<ul class="nav nav-tabs" style="margin-bottom:15px"> <ul class="nav nav-tabs" style="margin-bottom:15px">
{% for category, _ in categories %} {% for category, _ in categories_with_aks %}
<li class="nav-item"> <li class="nav-item">
<a class="nav-link {% if forloop.first %}active{% endif %}" data-toggle="tab" <a class="nav-link {% if forloop.first %}active{% endif %}" data-toggle="tab"
href="#category_{{ category.pk }}">{{ category.name }}</a> href="#category_{{ category.pk }}">{{ category.name }}</a>
...@@ -79,7 +79,7 @@ ...@@ -79,7 +79,7 @@
</ul> </ul>
<div id="akListTabbed" class="tab-content"> <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 }}"> <div class="tab-pane fade {% if forloop.first %}show active{% endif %}" id="category_{{ category.pk }}">
<p><b>{{ category.name }}:</b> {{ category.description }}</p> <p><b>{{ category.name }}:</b> {{ category.description }}</p>
{% include "AKSubmission/ak_list_table.html" %} {% include "AKSubmission/ak_list_table.html" %}
......
...@@ -14,33 +14,30 @@ from AKSubmission.forms import AKWishForm, AKOwnerForm, AKEditForm, AKSubmission ...@@ -14,33 +14,30 @@ from AKSubmission.forms import AKWishForm, AKOwnerForm, AKEditForm, AKSubmission
class SubmissionOverviewView(FilterByEventSlugMixin, ListView): class SubmissionOverviewView(FilterByEventSlugMixin, ListView):
model = AK model = AKCategory
context_object_name = "AKs" context_object_name = "categories"
template_name = "AKSubmission/submission_overview.html" template_name = "AKSubmission/submission_overview.html"
ordering = ['category']
def get_context_data(self, *, object_list=None, **kwargs): def get_context_data(self, *, object_list=None, **kwargs):
context = super().get_context_data(object_list=object_list, **kwargs) context = super().get_context_data(object_list=object_list, **kwargs)
# Sort AKs into different lists (by their category) # Sort AKs into different lists (by their category)
categories = []
aks_for_category = []
ak_wishes = [] ak_wishes = []
current_category = None categories_with_aks = []
for ak in context["AKs"]:
if ak.category != current_category: for category in context["categories"]:
current_category = ak.category aks_for_category = []
aks_for_category = [] for ak in category.ak_set.all():
categories.append((current_category, aks_for_category)) if settings.WISHES_AS_CATEGORY and ak.wish:
if settings.WISHES_AS_CATEGORY and ak.wish: ak_wishes.append(ak)
ak_wishes.append(ak) else:
else: aks_for_category.append(ak)
aks_for_category.append(ak) categories_with_aks.append((category, aks_for_category))
if settings.WISHES_AS_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)) ({"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) # Get list of existing owners for event (for AK submission start)
context["existingOwners"] = AKOwner.objects.filter(event=self.event) 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