diff --git a/seminar/static/images/logomm.pdf b/seminar/static/images/logomm.pdf new file mode 100644 index 00000000..320aa901 Binary files /dev/null and b/seminar/static/images/logomm.pdf differ diff --git a/seminar/static/seminar/stvrzenka.sty b/seminar/static/seminar/stvrzenka.sty deleted file mode 100644 index cedbc4f4..00000000 --- a/seminar/static/seminar/stvrzenka.sty +++ /dev/null @@ -1,24 +0,0 @@ -\newcommand{\stvrzenka}[6]{ - \removelastskip\bigskip - \newpage - - \noindent\textbf{Dodavatel:}\hfill\textbf{Stvrzenka č. {\Large #1}} - - {Univerzita Karlova \\ - \indent Matematicko-fyzikální fakulta \\ - \indent OPMK, M\&M \\ - \indent Ke Karlovu 3, 120 00 Praha 2 \\ - \indent IČ: 00216208 DIČ: CZ00216208} - - \parindent=0pt - \parskip=0.2in - - \textbf{Celkem Kč:} 700,- \\ - \textbf{Slovy:} sedmset korun českých - - \textbf{Přijato od (firma, jméno, adresa):} #2 #3, #4, #5 #6 - - \textbf{Účel platby:} příspěvek na stravování - - ze dne \datum \hfill Přijal:\hspace{3cm} -} diff --git a/seminar/static/seminar/stvrzenky.tex b/seminar/static/seminar/stvrzenky.tex index b3c21cfc..048bf2cb 100644 --- a/seminar/static/seminar/stvrzenky.tex +++ b/seminar/static/seminar/stvrzenky.tex @@ -1,13 +1,25 @@ -\documentclass[12pt,a4paper]{article} -\usepackage[czech]{babel} -\usepackage[utf8]{inputenc} -\usepackage[margin=1in]{geometry} +\input opmac +\chyph +\nopagenumbers +\parindent=0pt -\usepackage{stvrzenka} +\def\castka{700} -\pagestyle{empty} -\begin{document} +\newread\data +\openin\data=/dev/stdin +\read\data to\termin +\read\data to\misto -\input{ucastnici} +\loop + \read\data to\ucastnik + \unless\ifeof\data + \vbox{\picw=2cm\inspic logomm.pdf \smallskip\hrule\medskip + Potvrzujeme, že \ucastnik se zúčastnil(a) soustředění korespondenčního semináře M\&M konaného % \ucastnik má na konci mezeru + v~termínu \termin a že zaplatil(a) účastnický poplatek ve výši $\sim$\castka Kč$\sim$. % \termin též + \bigskip + \the\day.~\the\month.~\the\year, \misto\hfill Přijal(a): \hbox to 4cm{\hrulefill} + \bigskip + } +\repeat -\end{document} +\bye diff --git a/soustredeni/templates/soustredeni/seznam_soustredeni.html b/soustredeni/templates/soustredeni/seznam_soustredeni.html index 13d5e4ce..fcb7c287 100644 --- a/soustredeni/templates/soustredeni/seznam_soustredeni.html +++ b/soustredeni/templates/soustredeni/seznam_soustredeni.html @@ -44,7 +44,7 @@ HTML 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