Odevzdávátko: shlukování řešení podle deadline
This commit is contained in:
parent
a68e04abe0
commit
0b9110cf68
2 changed files with 13 additions and 3 deletions
|
@ -1,11 +1,15 @@
|
|||
{% extends "base.html" %}
|
||||
{% load deadliny %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
{% for dl, mnozina_reseni in reseni_podle_deadlinu.items %}
|
||||
<h1>{{ dl.2 | deadline_html }}</h1>
|
||||
<ul>
|
||||
{% for obj in object_list %}
|
||||
{% for obj in mnozina_reseni %}
|
||||
<li><a href="{% url 'odevzdavatko_detail_reseni' pk=obj.id %}">{{ obj }}</a> ({{ obj.get_forma_display }} {{ obj.cas_doruceni }})
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endfor %}
|
||||
|
||||
{% endblock %}
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in a new issue