From da988f27e6394437584f857da174f7aebc88a7a9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mat=C4=9Bj=20Koci=C3=A1n?= <matej.kocian@gmail.com>
Date: Wed, 9 Sep 2015 23:35:39 +0200
Subject: [PATCH] =?UTF-8?q?Fix:=20Ve=20v=C3=BDsl.=20zobraz=20body=20<=3D>?=
 =?UTF-8?q?=20=C5=99.=20se=20pokusil=20o=20=C5=99.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 seminar/views.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/seminar/views.py b/seminar/views.py
index 3ba98c08..13edd7d1 100644
--- a/seminar/views.py
+++ b/seminar/views.py
@@ -209,7 +209,10 @@ class CisloView(generic.DetailView):
             v.poradi = poradi
             v.body_celkem_rocnik = v.body
             v.body_celkem_odjakziva = VysledkyKCisluOdjakziva.objects.get(resitel=v.resitel, cislo=context['cislo']).body
-            v.body_ulohy = [0] * len(problemy)
+
+            # je tady '', aby se nezobrazovala 0, pokud se řešitel o řešení úlohy ani nepokusil
+            v.body_ulohy = [''] * len(problemy)
+
             v.titul = v.resitel.get_titul(v.body_celkem_odjakziva)
 
             body_cislo_q = VysledkyZaCislo.objects.filter(resitel=v.resitel, cislo=context['cislo'])
@@ -233,7 +236,8 @@ class CisloView(generic.DetailView):
 class ArchivTemataView(generic.ListView):
     model = Problem
     template_name = 'seminar/archiv/temata.html'
-    queryset = Problem.objects.filter(typ=Problem.TYP_TEMA).order_by('cislo_zadani__rocnik__rocnik', 'kod')
+    query = Problem.objects.filter(typ=Problem.TYP_TEMA).select_related('cislo_zadani__rocnik__rocnik').order_by('-cislo_zadani__rocnik__rocnik', 'kod')
+    queryset = [{"rocnik": r, "temata": list(x)} for r, x in groupby(query, lambda x: x.cislo_zadani.rocnik.rocnik)]
 
 ### Generovani vysledkovky