Přepsání stvrzenek do templates
This commit is contained in:
parent
2c9c1dc8e1
commit
c08e6c87f5
4 changed files with 48 additions and 43 deletions
|
@ -1,25 +0,0 @@
|
|||
\input opmac
|
||||
\chyph
|
||||
\nopagenumbers
|
||||
\parindent=0pt
|
||||
|
||||
\def\castka{1000}
|
||||
|
||||
\newread\data
|
||||
\openin\data=/dev/stdin
|
||||
\read\data to\termin
|
||||
\read\data to\misto
|
||||
|
||||
\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
|
||||
|
||||
\bye
|
37
soustredeni/templates/soustredeni/stvrzenky.tex
Normal file
37
soustredeni/templates/soustredeni/stvrzenky.tex
Normal file
|
@ -0,0 +1,37 @@
|
|||
{% autoescape off %}
|
||||
{% load static %}
|
||||
{% load tex %}
|
||||
\documentclass[11pt,a4paper]{article}
|
||||
\usepackage[left=0.75in, right=0.75in,top=0.5in,bottom=0.5in]{geometry}
|
||||
\usepackage[T1]{fontenc}
|
||||
\usepackage[utf8]{inputenc}
|
||||
\usepackage[czech]{babel}
|
||||
\usepackage{graphicx}
|
||||
\begin{document}
|
||||
\pagenumbering{gobble}
|
||||
\parindent=0pt
|
||||
|
||||
\def\stvrzenka#1#2{
|
||||
\vbox{%
|
||||
\includegraphics[width=2cm]{logomm.pdf}
|
||||
\smallskip\hrule\medskip
|
||||
{% with soustredeni as s %}
|
||||
Potvrzujeme, že #1 #2 se zúčastnil(a) soustředění Korespondenčního semináře M\&M konaného
|
||||
v~termínu {{s.datum_zacatku|date:"j.~n.~Y"|sloz}} --
|
||||
{{s.datum_konce|date:"j.~n.~Y"|sloz}} a~že zaplatil(a) účastnický poplatek ve
|
||||
výši $\sim${{castka|sloz}}Kč$\sim$.
|
||||
|
||||
\bigskip
|
||||
{{s.datum_zacatku|date:"j.~n.~Y"|sloz}}, {{s.misto|sloz}} \hfill Přijal(a): \hbox to 4cm{\hrulefill}
|
||||
\bigskip
|
||||
}
|
||||
{% endwith %}
|
||||
}
|
||||
|
||||
{% for u in ucastnici %}
|
||||
{% with o=u.osoba %}
|
||||
\stvrzenka{{o.jmeno|sloz}}{{o.prijmeni|sloz}}
|
||||
{% endwith %}
|
||||
{% endfor %}
|
||||
\end{document}
|
||||
{% endautoescape %}
|
|
@ -1,5 +0,0 @@
|
|||
{% 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 %}
|
|
@ -1,8 +1,9 @@
|
|||
from django.shortcuts import get_object_or_404
|
||||
from django.shortcuts import get_object_or_404, render
|
||||
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
|
||||
from django.contrib.staticfiles.finders import find
|
||||
from seminar.models import Soustredeni, Resitel, Soustredeni_Ucastnici, Nastaveni # Tohle je stare a chceme se toho zbavit. Pouzivejte s.ToCoChci
|
||||
import csv
|
||||
import tempfile
|
||||
import shutil
|
||||
|
@ -62,20 +63,17 @@ def soustredeniUcastniciExportView(request, soustredeni):
|
|||
def soustredeniStvrzenkyView(request, soustredeni):
|
||||
soustredeni = get_object_or_404(Soustredeni, id=soustredeni)
|
||||
ucastnici = Resitel.objects.filter(soustredeni=soustredeni)
|
||||
castka = Nastaveni.get_solo().cena_sous
|
||||
tex = render(request, 'soustredeni/stvrzenky.tex', {'ucastnici': ucastnici, 'soustredeni': soustredeni, 'castka': castka}).content
|
||||
|
||||
static = Path(settings.STATIC_ROOT)
|
||||
tempdir = Path(tempfile.mkdtemp())
|
||||
shutil.copy(static / 'images/logomm.pdf', tempdir)
|
||||
shutil.copy(static / 'seminar/stvrzenky.tex', tempdir)
|
||||
subprocess.run(
|
||||
['pdfcsplain', '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.tex", "w") as texfile:
|
||||
texfile.write(tex.decode())
|
||||
|
||||
with open(tempdir / 'stvrzenky.pdf', 'rb') as pdffile:
|
||||
shutil.copy(find('images/logomm.pdf'), tempdir)
|
||||
subprocess.call(["pdflatex", "stvrzenky.tex"], cwd = tempdir, stdout=subprocess.DEVNULL)
|
||||
|
||||
with open(tempdir / "stvrzenky.pdf", "rb") as pdffile:
|
||||
response = HttpResponse(pdffile.read(), content_type='application/pdf')
|
||||
shutil.rmtree(tempdir)
|
||||
return response
|
||||
|
|
Loading…
Reference in a new issue