From 0b9110cf6841bb583c263a453879f75a915fea2f Mon Sep 17 00:00:00 2001 From: "Pavel \"LEdoian\" Turinsky" Date: Tue, 6 Apr 2021 20:30:48 +0200 Subject: [PATCH] =?UTF-8?q?Odevzd=C3=A1v=C3=A1tko:=20shlukov=C3=A1n=C3=AD?= =?UTF-8?q?=20=C5=99e=C5=A1en=C3=AD=20podle=20deadline?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- seminar/templates/seminar/odevzdavatko/seznam.html | 6 +++++- seminar/views/odevzdavatko.py | 10 ++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) 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):