diff --git a/korektury/templates/korektury/opraf.html b/korektury/templates/korektury/opraf.html
index 04cfc2de..6a92f28c 100644
--- a/korektury/templates/korektury/opraf.html
+++ b/korektury/templates/korektury/opraf.html
@@ -7,7 +7,7 @@
Korektury {{pdf.nazev}}
-
+
Korektury {{pdf.nazev}}
{% if pdf.status = 'zanaseni' %} Probíhá zanášení korektur, zvažte, zda chcete přidávat nové
{% endif %}
{% if pdf.status = 'zastarale' %} Toto PDF je již zastaralé, nepřidávejte nové korektury
{% endif %}
@@ -192,9 +192,11 @@
["img-{{s.strana}}", [{% for o in s.op_id %}["op{{o.id}}",{{o.x}},{{o.y}}],{% endfor %}[]]],
{% endfor %}
[]]
- for (var i=0;iVygenerovat obálky pro účastníky
Seznam účastníků -
HTML tabulka pro tisk,
- CSV
+ CSV
+ Stvrzenky (42 v URL nahraďte prvním číslem z rozsahu)
{% endif %}
diff --git a/seminar/templates/seminar/soustredeni/ucastnici.tex b/seminar/templates/seminar/soustredeni/ucastnici.tex
new file mode 100644
index 00000000..a39885a6
--- /dev/null
+++ b/seminar/templates/seminar/soustredeni/ucastnici.tex
@@ -0,0 +1,5 @@
+{% load tex %}
+\newcommand{\datum}{{datum|date:"j. n. Y"|sloz}}
+{% for u in ucastnici %}
+\stvrzenka{{u.cislo_stvrzenky|sloz}}{{u.jmeno|sloz}}{{u.prijmeni|sloz}}{{u.ulice|sloz}}{{u.psc|sloz}}{{u.mesto|sloz}}
+{% endfor %}
diff --git a/seminar/urls.py b/seminar/urls.py
index 2c06e0fb..f7228b47 100644
--- a/seminar/urls.py
+++ b/seminar/urls.py
@@ -29,6 +29,7 @@ urlpatterns = [
name = 'seminar_seznam_soustredeni'),
url(r'^soustredeni/probehlo/(?P\d+)/$', views.SoustredeniView.as_view(), name='seminar_soustredeni'),
url(r'^soustredeni/(?P\d+)/seznam_ucastniku$', staff_member_required(views.SoustredeniUcastniciView.as_view()), name='soustredeni_ucastnici'),
+ url(r'^soustredeni/(?P\d+)/stvrzenky/(?P\d+)$', staff_member_required(views.soustredeniStvrzenkyExportView), name='soustredeni_stvrzenky'),
url(r'^soustredeni/(?P\d+)/export_ucastniku$', staff_member_required(views.soustredeniUcastniciExportView), name='soustredeni_ucastnici_export'),
url(r'^soustredeni/(?P\d+)/fotogalerie/', include('galerie.urls')),
diff --git a/seminar/views.py b/seminar/views.py
index 95df1a2e..141e9492 100644
--- a/seminar/views.py
+++ b/seminar/views.py
@@ -6,7 +6,7 @@ from django.core.urlresolvers import reverse
from django.core.exceptions import PermissionDenied, ObjectDoesNotExist
from django.views import generic
from django.utils.translation import ugettext as _
-from django.http import Http404
+from django.http import Http404,HttpResponseBadRequest
from django.db.models import Q
from django.views.decorators.csrf import ensure_csrf_cookie
from django.contrib.auth import authenticate, login
@@ -530,7 +530,7 @@ class SoustredeniView(generic.DetailView):
template_name = 'seminar/archiv/soustredeni.html'
def soustredeniObalkyView(request,soustredeni):
- soustredeni = Soustredeni.objects.filter(id = soustredeni)[0]
+ soustredeni = get_object_or_404(Soustredeni,id = soustredeni)
return obalkyView(request,soustredeni.ucastnici.all())
class SoustredeniUcastniciView(generic.ListView):
@@ -541,8 +541,31 @@ class SoustredeniUcastniciView(generic.ListView):
self.soustredeni = get_object_or_404(Soustredeni, id=self.kwargs["soustredeni"])
return Soustredeni_Ucastnici.objects.filter(soustredeni=self.soustredeni).select_related('resitel')
+def soustredeniStvrzenkyExportView(request,soustredeni,first_num):
+ first_num = int(first_num)
+ soustredeni = get_object_or_404(Soustredeni,id = soustredeni)
+ ucastnici = Resitel.objects.filter(soustredeni=soustredeni)
+ for (idx,u) in enumerate(ucastnici):
+ u.cislo_stvrzenky = first_num+idx;
+ tex = render(request,'seminar/soustredeni/ucastnici.tex', {'ucastnici': ucastnici, 'datum':soustredeni.datum_zacatku }).content
+
+ tempdir = tempfile.mkdtemp()
+ with open(tempdir+"/ucastnici.tex","w") as texfile:
+ # Pokud TeX chce ISO Latin, tak se da encode nastavit
+ texfile.write(tex.decode("utf-8").encode("utf-8"))
+ shutil.copy(os.path.join(settings.STATIC_ROOT, 'seminar/stvrzenka.sty'),tempdir)
+ shutil.copy(os.path.join(settings.STATIC_ROOT, 'seminar/stvrzenky.tex'),tempdir)
+ subprocess.call(["cslatex","stvrzenky.tex"],cwd = tempdir)
+ subprocess.call(["dvipdf","stvrzenky.dvi"],cwd = tempdir)
+
+ with open(tempdir+"/stvrzenky.pdf","rb") as pdffile:
+ response = HttpResponse(pdffile.read(),content_type='application/pdf')
+ shutil.rmtree(tempdir)
+ return response
+
+
def soustredeniUcastniciExportView(request,soustredeni):
- soustredeni = Soustredeni.objects.filter(id = soustredeni)[0]
+ soustredeni = get_object_or_404(Soustredeni,id = soustredeni)
ucastnici = Resitel.objects.filter(soustredeni=soustredeni)
response = HttpResponse(content_type='text/csv')
response['Content-Disposition'] = 'attachment; filename="ucastnici.csv"'