From 00b819c91830692ebed026b21a878055b967c384 Mon Sep 17 00:00:00 2001 From: "Bc. Petr Pecha" Date: Sun, 13 Sep 2015 18:18:05 +0200 Subject: [PATCH] Oprava odpoctu do reseni --- seminar/templates/seminar/titulnistrana.html | 25 ++++++++++---------- seminar/views.py | 19 ++++++++------- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/seminar/templates/seminar/titulnistrana.html b/seminar/templates/seminar/titulnistrana.html index 5958514f..a50fc42f 100644 --- a/seminar/templates/seminar/titulnistrana.html +++ b/seminar/templates/seminar/titulnistrana.html @@ -12,25 +12,26 @@ {% endblock %}{% endblock %} + {% if dead %}
Do konce odeslání řešení zbývá: - {{ted|timesince:dead}} - +
+ {% endif %}

My jsme M&M, mezioborový korespondenční seminář. diff --git a/seminar/views.py b/seminar/views.py index d7cdbfad..8762861b 100644 --- a/seminar/views.py +++ b/seminar/views.py @@ -48,14 +48,17 @@ class TitulniStranaView(generic.ListView): context = super(TitulniStranaView, self).get_context_data(**kwargs) nastaveni = get_object_or_404(Nastaveni) cas_deadline = nastaveni.aktualni_cislo.datum_deadline - rozdil_casu = datetime.combine(cas_deadline, datetime.max.time()) \ - - datetime.now() - context['cas_do_konce_dni'] = rozdil_casu.days - context['cas_do_konce_hodin'] = rozdil_casu.seconds / 3600 - context['cas_do_konce_minut'] = (rozdil_casu.seconds / 60) % 60 - context['cas_do_konce_sekund'] = rozdil_casu.seconds % 60 - context['dead'] = datetime.combine(cas_deadline, datetime.max.time()) - context['ted'] = datetime.now() + try: + rozdil_casu = datetime.combine(cas_deadline, datetime.max.time()) \ + - datetime.now() + context['cas_do_konce_dni'] = rozdil_casu.days + context['cas_do_konce_hodin'] = rozdil_casu.seconds / 3600 + context['cas_do_konce_minut'] = (rozdil_casu.seconds / 60) % 60 + context['cas_do_konce_sekund'] = rozdil_casu.seconds % 60 + context['dead'] = datetime.combine(cas_deadline, datetime.max.time()) + context['ted'] = datetime.now() + except: + context['dead'] = None return context class StareNovinkyView(generic.ListView):