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 = []