|
|
@ -8,6 +8,7 @@ from django.http import Http404 |
|
|
|
from django.db.models import Q, Sum, Count |
|
|
|
from django.views.generic.base import RedirectView |
|
|
|
from django.core.exceptions import PermissionDenied |
|
|
|
from django.contrib.staticfiles.finders import find |
|
|
|
|
|
|
|
import seminar.models as s |
|
|
|
import seminar.models as m |
|
|
@ -36,6 +37,7 @@ import unicodedata |
|
|
|
import logging |
|
|
|
import time |
|
|
|
from collections.abc import Sequence |
|
|
|
import http |
|
|
|
|
|
|
|
from seminar.utils import aktivniResitele |
|
|
|
|
|
|
@ -562,17 +564,25 @@ def cisloObalkyView(request, rocnik, cislo): |
|
|
|
|
|
|
|
|
|
|
|
def obalkyView(request, resitele): |
|
|
|
if len(resitele) == 0: |
|
|
|
return HttpResponse( |
|
|
|
render(request, 'universal.html', { |
|
|
|
'title': 'Není pro koho vyrobit obálky.', |
|
|
|
'text': 'Právě ses pokusil/a vygenerovat obálky pro prázdnou množinu lidí. Můžeš to zkusit změnit, případně se zeptej webařů :-)', |
|
|
|
}), |
|
|
|
status=http.HTTPStatus.NOT_FOUND, |
|
|
|
) |
|
|
|
|
|
|
|
tex = render(request,'seminar/archiv/obalky.tex', {'resitele': resitele}).content |
|
|
|
|
|
|
|
tempdir = tempfile.mkdtemp() |
|
|
|
with tempfile.TemporaryDirectory() as tempdir: |
|
|
|
with open(tempdir+"/obalky.tex","w") as texfile: |
|
|
|
texfile.write(tex.decode()) |
|
|
|
shutil.copy(os.path.join(settings.STATIC_ROOT, 'seminar/lisak.pdf'), tempdir) |
|
|
|
shutil.copy(find('seminar/lisak.pdf'), tempdir) |
|
|
|
subprocess.call(["pdflatex","obalky.tex"], cwd = tempdir) |
|
|
|
|
|
|
|
with open(tempdir+"/obalky.pdf","rb") as pdffile: |
|
|
|
response = HttpResponse(pdffile.read(), content_type='application/pdf') |
|
|
|
shutil.rmtree(tempdir) |
|
|
|
return response |
|
|
|
|
|
|
|
|
|
|
|