From ea26c48650e81d3cfb8940fe08920ca2d5a09e5a Mon Sep 17 00:00:00 2001 From: "Bc. Petr Pecha" Date: Sun, 13 Sep 2015 16:52:30 +0200 Subject: [PATCH 1/4] 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 From 543e0de243c7a6298428f815bd725e4560759491 Mon Sep 17 00:00:00 2001 From: "Bc. Petr Pecha" Date: Sun, 13 Sep 2015 17:06:22 +0200 Subject: [PATCH 2/4] Zobrazovani casu do konce TODO humanize --- seminar/templates/seminar/titulnistrana.html | 13 ++++++++++++- seminar/views.py | 11 +++++------ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/seminar/templates/seminar/titulnistrana.html b/seminar/templates/seminar/titulnistrana.html index d135e9e6..18c6184b 100644 --- a/seminar/templates/seminar/titulnistrana.html +++ b/seminar/templates/seminar/titulnistrana.html @@ -11,7 +11,18 @@
    - Do konce odeslání řešení zbývá: {{cas_do_konce}}. + Do konce odeslání řešení zbývá: + {# TODO humanize #} + {{cas_do_konce_dni}} dní + {% if cas_do_konce_dni < 5 %} + {{cas_do_konce_hodin}} hodin + {% if cas_do_konce_hodin < 5 %} + {{cas_do_konce_minut}} minut + {% if cas_do_konce_minut < 5 %} + {{cas_do_konce_sekund}} + {% endif %} + {% endif %} + {% endif %}

    diff --git a/seminar/views.py b/seminar/views.py index 5d29dfe2..7727548f 100644 --- a/seminar/views.py +++ b/seminar/views.py @@ -48,13 +48,12 @@ 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 - cas_do_konce = datetime.combine(cas_deadline, datetime.min.time()) \ + rozdil_casu = datetime.combine(cas_deadline, datetime.max.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" + 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 return context class StareNovinkyView(generic.ListView): From f1484662ecf439da7b16d973433a64aa029ff393 Mon Sep 17 00:00:00 2001 From: "Bc. Petr Pecha" Date: Sun, 13 Sep 2015 17:36:01 +0200 Subject: [PATCH 3/4] humanize odpocet --- mamweb/settings_common.py | 1 + seminar/templates/seminar/titulnistrana.html | 9 ++++++++- seminar/views.py | 2 ++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/mamweb/settings_common.py b/mamweb/settings_common.py index 0925a22e..a46085cf 100644 --- a/mamweb/settings_common.py +++ b/mamweb/settings_common.py @@ -106,6 +106,7 @@ INSTALLED_APPS = ( 'django_comments', 'django.contrib.flatpages', + 'django.contrib.humanize', # MaMweb 'mamweb', diff --git a/seminar/templates/seminar/titulnistrana.html b/seminar/templates/seminar/titulnistrana.html index 18c6184b..5958514f 100644 --- a/seminar/templates/seminar/titulnistrana.html +++ b/seminar/templates/seminar/titulnistrana.html @@ -1,5 +1,7 @@ {% extends 'base.html' %} +{% load humanize %} + {% block content %} @@ -12,7 +14,10 @@
    Do konce odeslání řešení zbývá: - {# TODO humanize #} + + {{ted|timesince:dead}} + + +

    diff --git a/seminar/views.py b/seminar/views.py index 7727548f..d7cdbfad 100644 --- a/seminar/views.py +++ b/seminar/views.py @@ -54,6 +54,8 @@ class TitulniStranaView(generic.ListView): 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() return context class StareNovinkyView(generic.ListView): From 0f8028db843ba30cddf50cb1388dc73c01e6ccdb Mon Sep 17 00:00:00 2001 From: "Bc. Petr Pecha" Date: Sun, 13 Sep 2015 18:07:27 +0200 Subject: [PATCH 4/4] Zviraznene menu a submenu clanky --- .../templates/seminar/clanky/organizatorske_clanky.html | 6 ++++++ seminar/templates/seminar/clanky/resitelske_clanky.html | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/seminar/templates/seminar/clanky/organizatorske_clanky.html b/seminar/templates/seminar/clanky/organizatorske_clanky.html index f2e00104..53f74009 100644 --- a/seminar/templates/seminar/clanky/organizatorske_clanky.html +++ b/seminar/templates/seminar/clanky/organizatorske_clanky.html @@ -1,5 +1,11 @@ {% extends 'seminar/clanky/resitelske_clanky.html' %} +{% block submenu %} + {% with "org" as selected %} + {% include "seminar/clanky/submenu.html" %} + {% endwith %} +{% endblock submenu %} + {% block nadpis1a %}{% block nadpis1b %} Organizátorské články {% endblock %}{% endblock %} diff --git a/seminar/templates/seminar/clanky/resitelske_clanky.html b/seminar/templates/seminar/clanky/resitelske_clanky.html index 6f34f3dc..b588c1f2 100644 --- a/seminar/templates/seminar/clanky/resitelske_clanky.html +++ b/seminar/templates/seminar/clanky/resitelske_clanky.html @@ -1,5 +1,13 @@ {% extends 'base.html' %} +{% block menu_clanky %}selected{% endblock %} + +{% block submenu %} + {% with "resitel" as selected %} + {% include "seminar/clanky/submenu.html" %} + {% endwith %} +{% endblock submenu %} + {% block content %}