diff --git a/seminar/templates/seminar/cislo.html b/seminar/templates/seminar/cislo.html
new file mode 100644
index 00000000..f31a747f
--- /dev/null
+++ b/seminar/templates/seminar/cislo.html
@@ -0,0 +1,32 @@
+{% extends "base.html" %}
+{% load staticfiles sekizai_tags %}
+
+{% block content %}
+
+
Číslo {{ cislo }} [id {{ cislo.id}}]
+
+
+
+ #
+ | Jméno
+ {% for p in problemy %}
+ | {{ p.cislo_zadani.cislo }}.{{ p.kod }}
+ {% endfor %}
+ | Sum
+ | Celkem
+ {% for rv in vysledkovka %}
+ |
+ {{ rv.poradi }}
+ | {{ rv.resitel.plne_jmeno }} [{{ rv.resitel.id }}]
+ {% for b in rv.body %}
+ | {{ b }}
+ {% endfor %}
+ | {{ rv.vysledek.body |default:0 }}
+ | {{ rv.vysledek.body_celkem }}
+ |
+ {% endfor %}
+
+
+
+{% endblock content %}
+
diff --git a/seminar/urls.py b/seminar/urls.py
index 79b55192..b8b7e486 100644
--- a/seminar/urls.py
+++ b/seminar/urls.py
@@ -3,4 +3,5 @@ from . import views
urlpatterns = patterns('',
url(r'^problem/(?P\d+)/$', views.ProblemView.as_view(), name='problem'),
+ url(r'^cislo/(?P\d+)/$', views.CisloView.as_view(), name='cislo'),
)
diff --git a/seminar/views.py b/seminar/views.py
index 44124d1e..2bcf34fd 100644
--- a/seminar/views.py
+++ b/seminar/views.py
@@ -2,7 +2,7 @@ from django.shortcuts import get_object_or_404, render
from django.http import HttpResponseRedirect
from django.core.urlresolvers import reverse
from django.views import generic
-from .models import Problem, Cislo
+from .models import Problem, Cislo, Reseni, VysledkyKCislu
# Create your views here.
@@ -10,8 +10,44 @@ class ProblemView(generic.DetailView):
model = Problem
template_name = 'seminar/problem.html'
+class RadekVysledkovky(object):
+ pass
+
class CisloView(generic.DetailView):
model = Cislo
template_name = 'seminar/cislo.html'
+ def get_context_data(self, **kwargs):
+ context = super(CisloView, self).get_context_data(**kwargs)
+
+ vysledky = VysledkyKCislu.objects.filter(cislo = context['cislo']).select_related("resitel")
+ reseni = Reseni.objects.filter(cislo_body = context['cislo']).select_related("resitel")
+
+ problemy = sorted(list(set([r.problem for r in reseni])), key=lambda x:x.kod)
+ problem_index = {}
+ for i in range(len(problemy)):
+ problem_index[problemy[i].id] = i
+
+ vysledky_resitele = {}
+ vysledkovka = []
+ posledni_body = 100000
+ for vi in range(len(vysledky)):
+ v = vysledky[vi]
+ tv = RadekVysledkovky()
+ tv.resitel = v.resitel
+ tv.vysledek = v
+ tv.body = ['']*len(problemy)
+ tv.poradi = ''
+ if posledni_body > v.body_celkem:
+ posledni_body = v.body_celkem
+ tv.poradi = vi + 1
+ vysledky_resitele[v.resitel.id] = tv
+ vysledkovka.append(tv)
+
+ for r in reseni:
+ vysledky_resitele[r.resitel.id].body[problem_index[r.problem.id]] = r.body
+
+ context['vysledkovka'] = vysledkovka
+ context['problemy'] = problemy
+ return context