diff --git a/seminar/templates/seminar/odevzdavatko/seznam.html b/seminar/templates/seminar/odevzdavatko/seznam.html index b58dcb54..2b3f332a 100644 --- a/seminar/templates/seminar/odevzdavatko/seznam.html +++ b/seminar/templates/seminar/odevzdavatko/seznam.html @@ -1,11 +1,15 @@ {% extends "base.html" %} +{% load deadliny %} {% block content %} +{% for dl, mnozina_reseni in reseni_podle_deadlinu.items %} +

{{ dl.2 | deadline_html }}

+{% endfor %} {% endblock %} diff --git a/seminar/views/odevzdavatko.py b/seminar/views/odevzdavatko.py index 5c64bc11..4a58be05 100644 --- a/seminar/views/odevzdavatko.py +++ b/seminar/views/odevzdavatko.py @@ -8,12 +8,13 @@ from django.db import transaction from dataclasses import dataclass import datetime +from itertools import groupby import logging import seminar.models as m import seminar.forms as f from seminar.forms import OdevzdavatkoTabulkaFiltrForm as FiltrForm -from seminar.utils import aktivniResitele, resi_v_rocniku +from seminar.utils import aktivniResitele, resi_v_rocniku, deadline logger = logging.getLogger(__name__) @@ -169,7 +170,12 @@ class ReseniProblemuView(MultipleObjectTemplateResponseMixin, MultipleObjectMixi return redirect(reverse("odevzdavatko_detail_reseni", kwargs={"pk": jedine_reseni.id})) context = self.get_context_data() return self.render_to_response(context) - # Kontext automaticky? + + def get_context_data(self, *args, **kwargs): + ctx = super().get_context_data(*args, **kwargs) + # FIXME: Lepší by bylo předat groupby do template. + ctx['reseni_podle_deadlinu'] = {k: list(v) for k,v in groupby(ctx['object_list'], lambda r: deadline(r.cas_doruceni))} + return ctx ## XXX: https://docs.djangoproject.com/en/3.1/topics/class-based-views/mixins/#avoid-anything-more-complex class DetailReseniView(DetailView):