Pridana tabulka pro obalkovani, beze stylu.

This commit is contained in:
Tomas 'Jethro' Pokorny 2016-01-06 19:36:15 +01:00
parent b2c3f96f8d
commit 7285d6ad89
3 changed files with 51 additions and 3 deletions

View file

@ -0,0 +1,22 @@
{% extends "seminar/archiv/base.html" %}
{% block content %}
<h1> K obálkování </h1>
<table>
<th>
<td>Jméno</td>
{% for u in ulohy %}
<td>{{u.nazev}}
{% endfor %}
</th>
{% for row in kdoco %}
<tr>
{% for cell in row%}
<td>{{cell}}</td>
{% endfor %}
</tr>
{% endfor %}
</table>
{% endblock content %}

View file

@ -1,7 +1,10 @@
from django.conf.urls import * # NOQA from django.conf.urls import * # NOQA
from django.conf.urls import patterns, url from django.conf.urls import patterns, url
from django.contrib.auth.decorators import user_passes_test
from . import views, export from . import views, export
staff_member_required = user_passes_test(lambda u: u.is_staff)
urlpatterns = patterns('', urlpatterns = patterns('',
url(r'^co-je-MaM/organizatori/$', views.CojemamOrganizatoriView.as_view(), name='organizatori'), url(r'^co-je-MaM/organizatori/$', views.CojemamOrganizatoriView.as_view(), name='organizatori'),
@ -38,6 +41,7 @@ urlpatterns = patterns('',
url(r'^cislo/(?P<rocnik>\d+).(?P<cislo>\d+)/vysledkovka.tex$', views.CisloVysledkovkaView.as_view(), name='seminar_cislo_vysledkovka'), url(r'^cislo/(?P<rocnik>\d+).(?P<cislo>\d+)/vysledkovka.tex$', views.CisloVysledkovkaView.as_view(), name='seminar_cislo_vysledkovka'),
url(r'^cislo/(?P<rocnik>\d+).(?P<cislo>\d+)/obalky.pdf$',views.cisloObalkyView, name='seminar_cislo_obalky'), url(r'^cislo/(?P<rocnik>\d+).(?P<cislo>\d+)/obalky.pdf$',views.cisloObalkyView, name='seminar_cislo_obalky'),
url(r'^cislo/(?P<rocnik>\d+).(?P<cislo>\d+)/tituly.tex$', views.TitulyView, url(r'^cislo/(?P<rocnik>\d+).(?P<cislo>\d+)/tituly.tex', views.TitulyView,name='seminar_cislo_titul'),
name='seminar_cislo_titul'), url(r'^cislo/(?P<rocnik>\d+).(?P<cislo>\d+)/resitel_uloha.html$',
staff_member_required(views.resitelUlohaView),name='seminar_cislo_resitel_uloha'),
) )

View file

@ -3,7 +3,7 @@
from django.shortcuts import get_object_or_404, render from django.shortcuts import get_object_or_404, render
from django.http import HttpResponse, HttpResponseRedirect, HttpResponseForbidden from django.http import HttpResponse, HttpResponseRedirect, HttpResponseForbidden
from django.core.urlresolvers import reverse 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.views import generic
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
from django.http import Http404 from django.http import Http404
@ -404,6 +404,28 @@ def obalkyView(request,resitele):
shutil.rmtree(tempdir) shutil.rmtree(tempdir)
return response 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 ### Tituly
# TODO udelat neco jako get_objects_or_404 # TODO udelat neco jako get_objects_or_404