From ea26c48650e81d3cfb8940fe08920ca2d5a09e5a Mon Sep 17 00:00:00 2001 From: "Bc. Petr Pecha" Date: Sun, 13 Sep 2015 16:52:30 +0200 Subject: [PATCH] Staticky odpocet --- seminar/templates/seminar/titulnistrana.html | 5 +++++ seminar/views.py | 17 +++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/seminar/templates/seminar/titulnistrana.html b/seminar/templates/seminar/titulnistrana.html index 27ab9042..d135e9e6 100644 --- a/seminar/templates/seminar/titulnistrana.html +++ b/seminar/templates/seminar/titulnistrana.html @@ -9,6 +9,11 @@ Tož vitajte! {% endblock %}{% endblock %} + +
+ Do konce odeslání řešení zbývá: {{cas_do_konce}}. +
+

My jsme M&M, mezioborový korespondenční seminář.
  • Mezioborový: matematika, fyzika, informatika. diff --git a/seminar/views.py b/seminar/views.py index e2549fd7..320ec359 100644 --- a/seminar/views.py +++ b/seminar/views.py @@ -11,7 +11,7 @@ from .models import Problem, Cislo, Reseni, Nastaveni, Rocnik, Soustredeni, Orga from .models import VysledkyZaCislo, VysledkyKCisluZaRocnik, VysledkyKCisluOdjakziva from . import utils -from datetime import timedelta, date +from datetime import timedelta, date, datetime from itertools import groupby @@ -44,9 +44,18 @@ class TitulniStranaView(generic.ListView): template_name='seminar/titulnistrana.html' queryset = Novinky.objects.filter(zverejneno=True).order_by('-datum')[:5] - #def get_context_data(self, **kwargs): - # context = super(TitulniStranaView, self).get_context_data(**kwargs) - # return context + def get_context_data(self, **kwargs): + context = super(TitulniStranaView, self).get_context_data(**kwargs) + nastaveni = get_object_or_404(Nastaveni) + cas_deadline = nastaveni.aktualni_cislo.datum_deadline + cas_do_konce = datetime.combine(cas_deadline, datetime.min.time()) \ + - datetime.now() + context['cas_do_konce'] = \ + str(cas_do_konce.days) + " dní " + \ + str(cas_do_konce.seconds / 3600) + " hodin " + \ + str((cas_do_konce.seconds / 60) % 60)+" min " + \ + str(cas_do_konce.seconds % 60) + " sekund" + return context class StareNovinkyView(generic.ListView): model = Novinky