From f68e4528275fdd13065c00d435993e28640813e1 Mon Sep 17 00:00:00 2001 From: Karel Balej Date: Fri, 1 Apr 2022 18:52:12 +0200 Subject: [PATCH] =?UTF-8?q?generov=C3=A1n=C3=AD=20stvrzenek=20za=20platbu?= =?UTF-8?q?=20soust=C5=99ed=C4=9Bn=C3=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- seminar/static/images/logomm.pdf | Bin 0 -> 1767 bytes seminar/static/seminar/stvrzenka.sty | 24 -------------- seminar/static/seminar/stvrzenky.tex | 30 ++++++++++++------ .../soustredeni/seznam_soustredeni.html | 2 +- soustredeni/urls.py | 5 +++ soustredeni/views.py | 25 +++++++++++++++ 6 files changed, 52 insertions(+), 34 deletions(-) create mode 100644 seminar/static/images/logomm.pdf delete mode 100644 seminar/static/seminar/stvrzenka.sty diff --git a/seminar/static/images/logomm.pdf b/seminar/static/images/logomm.pdf new file mode 100644 index 0000000000000000000000000000000000000000..320aa9012c5b10f7e3d06d80749437de438c2969 GIT binary patch literal 1767 zcmY!laBqy2;{MB|Cp6Qd9V1}A})*$dJ$)3P!W)=Zdl zdg=U(1ry@dEQn8B^J3A^ED(ELC0!g65fD#Z=Kf*sLD>b8O zmIekEMhb>TW_kw3CKi_F3bA0l&iQ#IK+VMppn!#hqI*$(X#tYcA+~`{C(xO(QnoGwn^2s87qBPO_jR; z+PJpz#Fsy1NAKsIxVg%-%KeEM=U+ejx}ax1{+>p610OD15~KWLQ)ArD_6zb^r)|LB{`XvediS2z~CkOlp{qm^G(hTv5HGC zLJTj9Rj0m?4LX%m%;%n|G5esy9L2JScao;m`#-nd^CnzbBJS4zcOPzTnD?V*n(^QB zoiW$!#Gfx0ww!hC{KxBR?ni5XF`SNFFNK+-K`9KHqm9i?Vc887U67;*PCz7PX+*XK zWlC6*Mr7M!u%X_WDaF7n3d-3*@a$L$%E?H1!V<{5EafdwN8`jC78Dnd}b;G9^J zn3JClF&tP56+_D&gr3i2HTML tabulka pro tisk, CSV, E-maily
- + Stvrzenky {% endif %} diff --git a/soustredeni/urls.py b/soustredeni/urls.py index 9cbd2e1d..2e5a6136 100644 --- a/soustredeni/urls.py +++ b/soustredeni/urls.py @@ -23,6 +23,11 @@ urlpatterns = [ org_required(views.soustredeniUcastniciExportView), name='soustredeni_ucastnici_export' ), + path( + 'soustredeni//stvrzenky.pdf', + org_required(views.soustredeniStvrzenkyView), + name='soustredeni_ucastnici_stvrzenky' + ), path( 'soustredeni//obalky.pdf', org_required(views.soustredeniObalkyView), diff --git a/soustredeni/views.py b/soustredeni/views.py index 99ec0b03..a165892b 100644 --- a/soustredeni/views.py +++ b/soustredeni/views.py @@ -1,8 +1,13 @@ from django.shortcuts import get_object_or_404 from django.http import HttpResponse from django.views import generic +from django.conf import settings from seminar.models import Soustredeni, Resitel, Soustredeni_Ucastnici # Tohle je stare a chceme se toho zbavit. Pouzivejte s.ToCoChci import csv +import tempfile +import shutil +import subprocess +from pathlib import Path from seminar.views import obalkyView @@ -53,3 +58,23 @@ def soustredeniUcastniciExportView(request, soustredeni): o = u.osoba writer.writerow([o.jmeno, o.prijmeni, str(u.rok_maturity), o.telefon, o.email, o.ulice, o.mesto, o.psc, o.stat.name]) return response + +def soustredeniStvrzenkyView(request, soustredeni): + soustredeni = get_object_or_404(Soustredeni, id=soustredeni) + ucastnici = Resitel.objects.filter(soustredeni=soustredeni) + + static = Path(settings.STATIC_ROOT) + tempdir = Path(tempfile.mkdtemp()) + shutil.copy(static / 'images/logomm.pdf', tempdir) + subprocess.run( + ['pdfcsplain', static / 'seminar/stvrzenky.tex'], + cwd=tempdir, + encoding='utf-8', + input=f'{soustredeni.datum_zacatku.strftime("%-d.~%-m.~%Y")} -- {soustredeni.datum_konce.strftime("%-d.~%-m.~%Y")}\n{soustredeni.misto}\n' + + '\n'.join([f'{u.osoba.jmeno} {u.osoba.prijmeni}' for u in ucastnici]) + ) + + with open(tempdir / 'stvrzenky.pdf', 'rb') as pdffile: + response = HttpResponse(pdffile.read(), content_type='application/pdf') + shutil.rmtree(tempdir) + return response