Browse Source

Číslo: úprava seznamu pro obálkování

remotes/origin/Petr
Matěj Kocián 9 years ago
parent
commit
16fc060902
  1. 19
      seminar/templates/seminar/archiv/cislo.html
  2. 33
      seminar/templates/seminar/archiv/cislo_obalkovani.html
  3. 22
      seminar/templates/seminar/archiv/resitel_uloha.html
  4. 4
      seminar/urls.py
  5. 28
      seminar/views.py

19
seminar/templates/seminar/archiv/cislo.html

@ -28,14 +28,15 @@
</ul>
{% if user.is_staff %}
<div class="mam-org-only">
<h3> Orgovské odkazy </h3>
<ul>
<li><a href="obalky.pdf">Obálky (PDF)</a></li>
<li><a href="tituly.tex">Tituly (TeX)</a></li>
<li><a href="vysledkovka.tex">Výsledkovka (TeX)</a></li>
</ul>
</div>
<div class="mam-org-only">
<h3> Orgovské odkazy </h3>
<ul>
<li><a href="obalky.pdf">Obálky (PDF)</a></li>
<li><a href="tituly.tex">Tituly (TeX)</a></li>
<li><a href="vysledkovka.tex">Výsledkovka (TeX)</a></li>
<li><a href="obalkovani">Obálkování</a></li>
</ul>
</div>
{% endif %}
{% if cislo.verejna_vysledkovka %}
@ -61,7 +62,7 @@
{% for rv in vysledkovka %}
<tr>
<td class='border-r'>{% autoescape off %}{{ rv.poradi }}{% endautoescape %}
<th class='border-r'>
<th class='border-r'>
{% if rv.titul %}
{{ rv.titul }}<sup>MM</sup>
{% endif %}

33
seminar/templates/seminar/archiv/cislo_obalkovani.html

@ -0,0 +1,33 @@
{% extends "seminar/archiv/base.html" %}
{% block content %}
<h1>
{% block nadpis1a %}{% block nadpis1b %}
Obálkování {{ cislo }}
{% endblock %}{% endblock %}
</h1>
Obálkovat se budou tyto problémy:
<ul>
{% for p in problemy %}
<li> {{ p.kod_v_rocniku }} {{ p }}
{% endfor %}
</ul>
{% for r in reseni %}
{% ifchanged r.resitel %}
{% if not forloop.first %}
</ul>
{% endif %}
<h4>{{ r.resitel }}</h4>
<ul>
{% endifchanged %}
<li>
{{ r.problem.kod_v_rocniku }} {{ r.problem.nazev }} ({{ r.body }})
{% endfor %}
</ul>
{% endblock content %}

22
seminar/templates/seminar/archiv/resitel_uloha.html

@ -1,22 +0,0 @@
{% 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 %}

4
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<rocnik>\d+).(?P<cislo>[0-9-]+)/resitel_uloha.html$',
staff_member_required(views.resitelUlohaView), name='seminar_cislo_resitel_uloha'),
url(r'^cislo/(?P<rocnik>\d+).(?P<cislo>[0-9-]+)/obalkovani$',
staff_member_required(views.obalkovaniView), name='seminar_cislo_resitel_obalkovani'),
url(r'^soustredeni/(?P<soustredeni>\d+)/obalky.pdf',
staff_member_required(views.soustredeniObalkyView), name='seminar_soustredeni_obalky'),
]

28
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

Loading…
Cancel
Save