From 6c6417b23fe154bce77dcce0e5c5f2a690bbdf67 Mon Sep 17 00:00:00 2001 From: "Bc. Petr Pecha" Date: Mon, 7 Sep 2015 09:37:29 +0200 Subject: [PATCH 1/3] Aktualni zadani rozdeleno na ulohy, temata a serial --- .../templates/seminar/zadani/AktualniZadani.html | 15 +++++++++++---- seminar/views.py | 8 ++++++++ 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/seminar/templates/seminar/zadani/AktualniZadani.html b/seminar/templates/seminar/zadani/AktualniZadani.html index 70964b67..4e82f93f 100644 --- a/seminar/templates/seminar/zadani/AktualniZadani.html +++ b/seminar/templates/seminar/zadani/AktualniZadani.html @@ -10,14 +10,21 @@ {% endif %} {#TODO a co speciální deadline pro účast na soustředění? #} - {% for problem in ac.zadane_problemy.all %} + +

+ {% for sada in problemy%} + {% if sada %}

{% cycle 'Úlohy:' 'Témata:' 'Seriál:' %}

{% endif %} + {% for problem in sada %} {# TODO použít {{problem.kod_v_rocniku}} ? vrací 4.u1 místo 4.1 #} -

{{problem.cislo_zadani.cislo}}.{{problem.kod}} {{problem.nazev}} ({{problem.body}}b)

+

{{problem.cislo_zadani.cislo}}.{{problem.kod}} {{problem.nazev}} + {# nezobrazuj body, pokud nejsou zadane (typicky u temat)#} + {% if problem.body %}({{problem.body}}b){% endif %}

{% autoescape off %}{{problem.text_zadani}}{% endautoescape %}
- {% empty %} - Aktuálně nejsou zadané žádné úlohy k řešení. {% endfor %} + {% empty %} + Aktuálně nejsou zadané žádné úlohy k řešení. + {% endfor %} {% endwith %} diff --git a/seminar/views.py b/seminar/views.py index c654f60f..b57e9e8a 100644 --- a/seminar/views.py +++ b/seminar/views.py @@ -1,3 +1,5 @@ +# coding:utf-8 + from django.shortcuts import get_object_or_404, render from django.http import HttpResponseRedirect from django.core.urlresolvers import reverse @@ -12,8 +14,14 @@ from . import utils def AktualniZadaniView(request): nastaveni = get_object_or_404(Nastaveni) + problemy = Problem.objects.filter(cislo_zadani=nastaveni.aktualni_cislo) + ulohy = problemy.filter(typ = 'uloha') + temata = problemy.filter(typ = 'tema') + serialy = problemy.filter(typ = 'serial') + problemy = [ulohy, temata, serialy] return render(request, 'seminar/zadani/AktualniZadani.html', {'nastaveni' : nastaveni, + 'problemy' : problemy, }, ) ### Titulni strana From f6c5c11a1444870139a64a752e83023b8820e34c Mon Sep 17 00:00:00 2001 From: "Bc. Petr Pecha" Date: Mon, 7 Sep 2015 10:01:50 +0200 Subject: [PATCH 2/3] V aktualnim zadani zobraz jenom zadane ulohy --- seminar/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seminar/views.py b/seminar/views.py index b57e9e8a..6c7dfa69 100644 --- a/seminar/views.py +++ b/seminar/views.py @@ -14,7 +14,7 @@ from . import utils def AktualniZadaniView(request): nastaveni = get_object_or_404(Nastaveni) - problemy = Problem.objects.filter(cislo_zadani=nastaveni.aktualni_cislo) + problemy = Problem.objects.filter(cislo_zadani=nastaveni.aktualni_cislo).filter(stav = 'zadany') ulohy = problemy.filter(typ = 'uloha') temata = problemy.filter(typ = 'tema') serialy = problemy.filter(typ = 'serial') From ee46d10fe2508277a69f1c9fcd5c4e5cfce5faec Mon Sep 17 00:00:00 2001 From: "Bc. Petr Pecha" Date: Mon, 7 Sep 2015 10:02:19 +0200 Subject: [PATCH 3/3] Oprava cyklovani nadpisu --- seminar/templates/seminar/zadani/AktualniZadani.html | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/seminar/templates/seminar/zadani/AktualniZadani.html b/seminar/templates/seminar/zadani/AktualniZadani.html index 4e82f93f..6ca2e9e6 100644 --- a/seminar/templates/seminar/zadani/AktualniZadani.html +++ b/seminar/templates/seminar/zadani/AktualniZadani.html @@ -13,7 +13,11 @@

{% for sada in problemy%} - {% if sada %}

{% cycle 'Úlohy:' 'Témata:' 'Seriál:' %}

{% endif %} + {# podnadpisy, kdyz neni zakomentuje se nadpis #} + {% if not sada %}{% endif %} + {# publikace jednotlivych zadani #} {% for problem in sada %} {# TODO použít {{problem.kod_v_rocniku}} ? vrací 4.u1 místo 4.1 #}

{{problem.cislo_zadani.cislo}}.{{problem.kod}} {{problem.nazev}}