From 264283e6082d16909cfb3411a1c5c8069e0b68e2 Mon Sep 17 00:00:00 2001 From: "Pavel \"LEdoian\" Turinsky" Date: Tue, 26 Jan 2021 20:33:00 +0100 Subject: [PATCH] =?UTF-8?q?Revert=20"Deadliny=20na=20tituln=C3=AD=20stran?= =?UTF-8?q?=C4=9B=20-=20zobrazov=C3=A1n=C3=AD=20v=C5=A1ech"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 1127837499beffaaa557ceec5d335db59a936d0a. --- seminar/templates/seminar/titulnistrana.html | 48 ++++++++++---------- seminar/views/views_all.py | 26 ++++++----- 2 files changed, 38 insertions(+), 36 deletions(-) diff --git a/seminar/templates/seminar/titulnistrana.html b/seminar/templates/seminar/titulnistrana.html index 3f0e1d82..6a323bf9 100644 --- a/seminar/templates/seminar/titulnistrana.html +++ b/seminar/templates/seminar/titulnistrana.html @@ -1,3 +1,12 @@ + + {% extends 'base.html' %} {% load humanize %} @@ -6,34 +15,23 @@ {% block content %} -{% if deadline_soustredeni or preddeadline or deadline %} +{% if nejblizsi_deadline %}
-

- - - Do konce odeslání řešení - zbývá: -

- {% if deadline_soustredeni %} - {{deadline_soustredeni|timeuntil}} (pro - účast na soustředění) - {% endif %} -
-
- {% if preddeadline %} - {{preddeadline|timeuntil}} (do 1. deadline) - {% endif %} -
-
- {% if deadline %} - {{deadline|timeuntil}} (do deadline) - {% endif %} -
-
-
-

+

Do + {% if typ_deadline == 'soustredeni' %} + + deadlinu odeslání řešení + pro účast na soustředění + + {% elif typ_deadline == 'preddeadline' %} 1. deadlinu aktuálního čísla + {% else %} deadlinu aktuálního čísla + {% endif %}zbývá: + {{nejblizsi_deadline|timeuntil}}

{% endif %} +
diff --git a/seminar/views/views_all.py b/seminar/views/views_all.py index 43002f94..ecbe82fa 100644 --- a/seminar/views/views_all.py +++ b/seminar/views/views_all.py @@ -562,19 +562,23 @@ class TitulniStranaView(generic.ListView): context = super(TitulniStranaView, self).get_context_data(**kwargs) nastaveni = get_object_or_404(Nastaveni) - context['deadline_soustredeni'] = nastaveni.aktualni_cislo.datum_deadline_soustredeni - context['preddeadline'] = nastaveni.aktualni_cislo.datum_preddeadline - context['deadline'] = nastaveni.aktualni_cislo.datum_deadline - now = date.today() - - if context['deadline_soustredeni'] is not None and context['deadline_soustredeni'] < now: - context['deadline_soustredeni'] = None - if context['preddeadline'] is not None and context['preddeadline'] < now: - context['preddeadline'] = None - if context['deadline'] is not None and context['deadline'] < now: - context['deadline'] = None + deadline_soustredeni = (nastaveni.aktualni_cislo.datum_deadline_soustredeni, "soustredeni") + preddeadline = (nastaveni.aktualni_cislo.datum_preddeadline, "preddeadline") + deadline = (nastaveni.aktualni_cislo.datum_deadline, "deadline") + try: + nejblizsi_deadline = sorted(filter(lambda dl: dl[0] is not None and dl[0] >= date.today(), [deadline_soustredeni, preddeadline, deadline]))[0] + if nejblizsi_deadline[0] == deadline_soustredeni[0]: + nejblizsi_deadline = deadline_soustredeni + except IndexError: + nejblizsi_deadline = (None, None) # neni zadna aktualni deadline + + if nejblizsi_deadline[0] is not None: + context['nejblizsi_deadline'] = datetime.combine(nejblizsi_deadline[0], datetime.max.time()) + else: + context['nejblizsi_deadline'] = None + context['typ_deadline'] = nejblizsi_deadline[1] # Aktuální témata nazvy_a_odkazy_na_aktualni_temata = []