diff --git a/AKModel/templates/admin/AKModel/export/slides.tex b/AKModel/templates/admin/AKModel/export/slides.tex index d7c9ce62fa8b7929c8b33271435af56bb5536a1f..814c57ed15d5fb8199ba90cf265c49fbae4e1bdb 100644 --- a/AKModel/templates/admin/AKModel/export/slides.tex +++ b/AKModel/templates/admin/AKModel/export/slides.tex @@ -28,11 +28,11 @@ \end{frame} -{%for category in categories %} +{%for category, ak_list in categories_with_aks %} \section{ {{- category.name | latex_escape_utf8 -}} } - {% for ak in category.ak_set.all() %} + {% for ak, next_aks in ak_list %} {% if not ak.wish %} @@ -51,7 +51,15 @@ \faScroll {% endif %} - {{ ak.description | truncatechars(500) | latex_escape_utf8 }} + {{ ak.description | truncatechars(400) | latex_escape_utf8 }} + + \vspace{2em} + + \begin{scriptsize} + {% for n_ak in next_aks %} + {% if n_ak %}\hfill \faAngleDoubleRight~ {{- n_ak.name | latex_escape_utf8 -}}{% endif %} + {% endfor %} + \end{scriptsize} \end{frame} @@ -64,7 +72,7 @@ \section{ {{- translations.wishes -}} } -{% for ak in wishes %} +{% for ak, next_aks in wishes %} %\setbeamertemplate{frame footer}{} @@ -79,7 +87,15 @@ \faClock~ - {{ ak.description | truncatechars(500) | latex_escape_utf8 }} + {{ ak.description | truncatechars(400) | latex_escape_utf8 }} + + \vspace{2em} + + \begin{scriptsize} + {% for n_ak in next_aks %} + {% if n_ak %}\hfill \faAngleDoubleRight~ {{- n_ak.name | latex_escape_utf8 -}}{% endif %} + {% endfor %} + \end{scriptsize} \end{frame} diff --git a/AKModel/views.py b/AKModel/views.py index b620f1e78dff1229492869c90f00585caaf13ea8..06bd32113b7a617a8920b16ef03459c252bc50e3 100644 --- a/AKModel/views.py +++ b/AKModel/views.py @@ -1,3 +1,5 @@ +from itertools import zip_longest + from django.contrib import admin, messages from django.contrib.admin.views.decorators import staff_member_required from django.http import HttpResponseRedirect @@ -296,6 +298,8 @@ def export_slides(request, event_slug): event = get_object_or_404(Event, slug=event_slug) + NEXT_AK_LIST_LENGTH = 4 + translations = { 'symbols': _("Symbols"), 'who': _("Who?"), @@ -305,11 +309,27 @@ def export_slides(request, event_slug): 'wishes': _("Wishes"), } + def build_ak_list_with_next_aks(ak_list): + next_aks_list = zip_longest(*[ak_list[i + 1:] for i in range(NEXT_AK_LIST_LENGTH)], fillvalue=None) + return [(ak, next_aks) for ak, next_aks in zip_longest(ak_list, next_aks_list, fillvalue=list())] + + categories = event.akcategory_set.all() + categories_with_aks = [] + ak_wishes = [] + for category in categories: + ak_list = [] + for ak in category.ak_set.all(): # order_by("owners").distinct(): + if ak.wish: + ak_wishes.append(ak) + else: + ak_list.append(ak) + categories_with_aks.append((category, build_ak_list_with_next_aks(ak_list))) + context = { 'title': event.name, - 'categories': event.akcategory_set.all(), + 'categories_with_aks': categories_with_aks, 'subtitle': _("AKs"), - "wishes": [ak for ak in event.ak_set.order_by('category') if ak.wish], + "wishes": build_ak_list_with_next_aks(ak_wishes), "translations": translations, }