generování stvrzenek za platbu soustředění
This commit is contained in:
		
							parent
							
								
									6b3cba10bb
								
							
						
					
					
						commit
						f68e452827
					
				
					 6 changed files with 52 additions and 34 deletions
				
			
		
							
								
								
									
										
											BIN
										
									
								
								seminar/static/images/logomm.pdf
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								seminar/static/images/logomm.pdf
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							|  | @ -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} |  | ||||||
| } |  | ||||||
|  | @ -1,13 +1,25 @@ | ||||||
| \documentclass[12pt,a4paper]{article} | \input opmac | ||||||
| \usepackage[czech]{babel} | \chyph | ||||||
| \usepackage[utf8]{inputenc} | \nopagenumbers | ||||||
| \usepackage[margin=1in]{geometry} | \parindent=0pt | ||||||
| 
 | 
 | ||||||
| \usepackage{stvrzenka} | \def\castka{700} | ||||||
| 
 | 
 | ||||||
| \pagestyle{empty} | \newread\data | ||||||
| \begin{document} | \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 | ||||||
|  |  | ||||||
|  | @ -44,7 +44,7 @@ | ||||||
|           <a href="../{{soustredeni.pk}}/seznam_ucastniku">HTML tabulka pro tisk</a>, |           <a href="../{{soustredeni.pk}}/seznam_ucastniku">HTML tabulka pro tisk</a>, | ||||||
|           <a href="../{{soustredeni.pk}}/export_ucastniku">CSV</a>, |           <a href="../{{soustredeni.pk}}/export_ucastniku">CSV</a>, | ||||||
|           <a href="../{{soustredeni.pk}}/maily_ucastniku">E-maily</a><br> |           <a href="../{{soustredeni.pk}}/maily_ucastniku">E-maily</a><br> | ||||||
|           <!--a href="../{{soustredeni.pk}}/stvrzenky/42">Stvrzenky <i>(42 v URL nahraďte prvním číslem z rozsahu)</i></a!--> |           <a href="../{{soustredeni.pk}}/stvrzenky.pdf">Stvrzenky</a> | ||||||
|         </div> |         </div> | ||||||
|       {% endif %} |       {% endif %} | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -23,6 +23,11 @@ urlpatterns = [ | ||||||
| 		org_required(views.soustredeniUcastniciExportView), | 		org_required(views.soustredeniUcastniciExportView), | ||||||
| 		name='soustredeni_ucastnici_export' | 		name='soustredeni_ucastnici_export' | ||||||
| 	), | 	), | ||||||
|  | 	path( | ||||||
|  | 		'soustredeni/<int:soustredeni>/stvrzenky.pdf', | ||||||
|  | 		org_required(views.soustredeniStvrzenkyView), | ||||||
|  | 		name='soustredeni_ucastnici_stvrzenky' | ||||||
|  | 	), | ||||||
| 	path( | 	path( | ||||||
| 		'soustredeni/<int:soustredeni>/obalky.pdf', | 		'soustredeni/<int:soustredeni>/obalky.pdf', | ||||||
| 		org_required(views.soustredeniObalkyView), | 		org_required(views.soustredeniObalkyView), | ||||||
|  |  | ||||||
|  | @ -1,8 +1,13 @@ | ||||||
| from django.shortcuts import get_object_or_404 | from django.shortcuts import get_object_or_404 | ||||||
| from django.http import HttpResponse | from django.http import HttpResponse | ||||||
| from django.views import generic | 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 seminar.models import Soustredeni, Resitel, Soustredeni_Ucastnici # Tohle je stare a chceme se toho zbavit. Pouzivejte s.ToCoChci | ||||||
| import csv | import csv | ||||||
|  | import tempfile | ||||||
|  | import shutil | ||||||
|  | import subprocess | ||||||
|  | from pathlib import Path | ||||||
| 
 | 
 | ||||||
| from seminar.views import obalkyView | from seminar.views import obalkyView | ||||||
| 
 | 
 | ||||||
|  | @ -53,3 +58,23 @@ def soustredeniUcastniciExportView(request, soustredeni): | ||||||
| 		o = u.osoba | 		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]) | 		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 | 	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 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue