From 7285d6ad897a631af371e82240d6179cea9637b0 Mon Sep 17 00:00:00 2001 From: Tomas 'Jethro' Pokorny Date: Wed, 6 Jan 2016 19:36:15 +0100 Subject: [PATCH] Pridana tabulka pro obalkovani, beze stylu. --- .../seminar/archiv/resitel_uloha.html | 22 +++++++++++++++++ seminar/urls.py | 8 +++++-- seminar/views.py | 24 ++++++++++++++++++- 3 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 seminar/templates/seminar/archiv/resitel_uloha.html diff --git a/seminar/templates/seminar/archiv/resitel_uloha.html b/seminar/templates/seminar/archiv/resitel_uloha.html new file mode 100644 index 00000000..f61ee704 --- /dev/null +++ b/seminar/templates/seminar/archiv/resitel_uloha.html @@ -0,0 +1,22 @@ + +{% 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 bf5f113e..33b4fc6e 100644 --- a/seminar/urls.py +++ b/seminar/urls.py @@ -1,7 +1,10 @@ from django.conf.urls import * # NOQA from django.conf.urls import patterns, url +from django.contrib.auth.decorators import user_passes_test from . import views, export +staff_member_required = user_passes_test(lambda u: u.is_staff) + urlpatterns = patterns('', url(r'^co-je-MaM/organizatori/$', views.CojemamOrganizatoriView.as_view(), name='organizatori'), @@ -38,6 +41,7 @@ urlpatterns = patterns('', url(r'^cislo/(?P\d+).(?P\d+)/vysledkovka.tex$', views.CisloVysledkovkaView.as_view(), name='seminar_cislo_vysledkovka'), url(r'^cislo/(?P\d+).(?P\d+)/obalky.pdf$',views.cisloObalkyView, name='seminar_cislo_obalky'), - url(r'^cislo/(?P\d+).(?P\d+)/tituly.tex$', views.TitulyView, - name='seminar_cislo_titul'), + url(r'^cislo/(?P\d+).(?P\d+)/tituly.tex', views.TitulyView,name='seminar_cislo_titul'), + url(r'^cislo/(?P\d+).(?P\d+)/resitel_uloha.html$', + staff_member_required(views.resitelUlohaView),name='seminar_cislo_resitel_uloha'), ) diff --git a/seminar/views.py b/seminar/views.py index 93945778..5049cd66 100644 --- a/seminar/views.py +++ b/seminar/views.py @@ -3,7 +3,7 @@ from django.shortcuts import get_object_or_404, render from django.http import HttpResponse, HttpResponseRedirect, HttpResponseForbidden from django.core.urlresolvers import reverse -from django.core.exceptions import PermissionDenied +from django.core.exceptions import PermissionDenied, ObjectDoesNotExist from django.views import generic from django.utils.translation import ugettext as _ from django.http import Http404 @@ -404,6 +404,28 @@ def obalkyView(request,resitele): shutil.rmtree(tempdir) return response +def resitelUlohaView(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}) + ### Tituly # TODO udelat neco jako get_objects_or_404