From 16fc060902af47612311574e45bb74bb39df5a04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C4=9Bj=20Koci=C3=A1n?= Date: Tue, 26 Jan 2016 00:24:05 +0100 Subject: [PATCH] =?UTF-8?q?=C4=8C=C3=ADslo:=20=C3=BAprava=20seznamu=20pro?= =?UTF-8?q?=20ob=C3=A1lkov=C3=A1n=C3=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- seminar/templates/seminar/archiv/cislo.html | 19 ++++++----- .../seminar/archiv/cislo_obalkovani.html | 33 +++++++++++++++++++ .../seminar/archiv/resitel_uloha.html | 22 ------------- seminar/urls.py | 4 +-- seminar/views.py | 28 +++++----------- 5 files changed, 53 insertions(+), 53 deletions(-) create mode 100644 seminar/templates/seminar/archiv/cislo_obalkovani.html delete mode 100644 seminar/templates/seminar/archiv/resitel_uloha.html diff --git a/seminar/templates/seminar/archiv/cislo.html b/seminar/templates/seminar/archiv/cislo.html index 56d75675..63038aac 100644 --- a/seminar/templates/seminar/archiv/cislo.html +++ b/seminar/templates/seminar/archiv/cislo.html @@ -28,14 +28,15 @@ {% if user.is_staff %} -
-

Orgovské odkazy

- -
+
+

Orgovské odkazy

+ +
{% endif %} {% if cislo.verejna_vysledkovka %} @@ -61,7 +62,7 @@ {% for rv in vysledkovka %} {% autoescape off %}{{ rv.poradi }}{% endautoescape %} - + {% if rv.titul %} {{ rv.titul }}MM {% endif %} diff --git a/seminar/templates/seminar/archiv/cislo_obalkovani.html b/seminar/templates/seminar/archiv/cislo_obalkovani.html new file mode 100644 index 00000000..dd0b0796 --- /dev/null +++ b/seminar/templates/seminar/archiv/cislo_obalkovani.html @@ -0,0 +1,33 @@ +{% extends "seminar/archiv/base.html" %} + +{% block content %} +

+ {% block nadpis1a %}{% block nadpis1b %} + Obálkování {{ cislo }} + {% endblock %}{% endblock %} +

+ + Obálkovat se budou tyto problémy: + + + {% for r in reseni %} + {% ifchanged r.resitel %} + {% if not forloop.first %} + + {% endif %} +

{{ r.resitel }}

+ + +{% endblock content %} diff --git a/seminar/templates/seminar/archiv/resitel_uloha.html b/seminar/templates/seminar/archiv/resitel_uloha.html deleted file mode 100644 index f61ee704..00000000 --- a/seminar/templates/seminar/archiv/resitel_uloha.html +++ /dev/null @@ -1,22 +0,0 @@ - -{% extends "seminar/archiv/base.html" %} - -{% block content %} -

K obálkování

- - -{% for u in ulohy %} - - {% for cell in row%} - - {% endfor %} - -{% endfor %} -
- Jméno{{u.nazev}} -{% endfor %} - -{% for row in kdoco %} -
{{cell}}
-{% endblock content %} - diff --git a/seminar/urls.py b/seminar/urls.py index 446d6bc7..968e5f02 100644 --- a/seminar/urls.py +++ b/seminar/urls.py @@ -45,8 +45,8 @@ urlpatterns = [ staff_member_required(views.TitulyView), name='seminar_cislo_titul'), url(r'^stav$', staff_member_required(views.StavDatabazeView), name='stav_databaze'), - url(r'^cislo/(?P\d+).(?P[0-9-]+)/resitel_uloha.html$', - staff_member_required(views.resitelUlohaView), name='seminar_cislo_resitel_uloha'), + url(r'^cislo/(?P\d+).(?P[0-9-]+)/obalkovani$', + staff_member_required(views.obalkovaniView), name='seminar_cislo_resitel_obalkovani'), url(r'^soustredeni/(?P\d+)/obalky.pdf', staff_member_required(views.soustredeniObalkyView), name='seminar_soustredeni_obalky'), ] diff --git a/seminar/views.py b/seminar/views.py index 4cd837b2..0f4c6e50 100644 --- a/seminar/views.py +++ b/seminar/views.py @@ -404,27 +404,15 @@ def obalkyView(request,resitele): shutil.rmtree(tempdir) return response -def resitelUlohaView(request,rocnik,cislo): +def obalkovaniView(request, rocnik, cislo): rocnik = Rocnik.objects.get(rocnik=rocnik) - cislo = Cislo.objects.get(rocnik=rocnik,cislo=cislo) - reseni = Reseni.objects.filter(cislo_body=cislo).order_by('resitel') - # TODO: Nasledujici 4 radky jsou fuj. Znate neco lepsiho? - resitele = list(set([r.resitel for r in reseni])) - resitele.sort(key=lambda r: (r.prijmeni,r.jmeno)) - ulohy = list(set([r.problem for r in reseni])) - ulohy.sort(key=lambda u: (u.typ,u.kod)) - - kdoco = [] - for r in resitele: - res_ulohy = [r.jmeno+" "+r.prijmeni] - for u in ulohy: - try: - rsni = reseni.get(resitel=r,problem=u) - res_ulohy.append(rsni.body) - except ObjectDoesNotExist: - res_ulohy.append("") - kdoco.append(res_ulohy) - return render(request, 'seminar/archiv/resitel_uloha.html',{'ulohy':ulohy,'kdoco':kdoco}) + cislo = Cislo.objects.get(rocnik=rocnik, cislo=cislo) + + reseni = Reseni.objects.filter(cislo_body=cislo) + serazena_reseni = sorted(reseni, key=lambda r: (r.resitel.prijmeni, r.resitel.jmeno, r.problem.typ, r.problem.kod)) + + problemy = sorted(set(r.problem for r in reseni), key=lambda p: (p.typ, p.kod)) + return render(request, 'seminar/archiv/cislo_obalkovani.html', {'cislo': cislo, 'problemy': problemy, 'reseni': serazena_reseni}) ### Tituly