Browse Source

Lepší složky i pro stvrzenky

pull/45/head
Pavel "LEdoian" Turinsky 8 months ago
parent
commit
88ae103ec1
  1. 16
      soustredeni/views.py

16
soustredeni/views.py

@ -79,14 +79,14 @@ def soustredeniStvrzenkyView(request, soustredeni):
castka = Nastaveni.get_solo().cena_sous castka = Nastaveni.get_solo().cena_sous
tex = render(request, 'soustredeni/stvrzenky.tex', {'ucastnici': ucastnici, 'soustredeni': soustredeni, 'castka': castka}).content tex = render(request, 'soustredeni/stvrzenky.tex', {'ucastnici': ucastnici, 'soustredeni': soustredeni, 'castka': castka}).content
tempdir = Path(tempfile.mkdtemp()) with tempfile.TemporaryDirectory() as tempdirfn:
with open(tempdir / "stvrzenky.tex", "w") as texfile: tempdir = Path(tempdirfn)
texfile.write(tex.decode()) with open(tempdir / "stvrzenky.tex", "w") as texfile:
texfile.write(tex.decode())
shutil.copy(find('images/logomm.pdf'), tempdir) shutil.copy(find('images/logomm.pdf'), tempdir)
subprocess.call(["pdflatex", "stvrzenky.tex"], cwd = tempdir, stdout=subprocess.DEVNULL) subprocess.call(["pdflatex", "stvrzenky.tex"], cwd = tempdir, stdout=subprocess.DEVNULL)
with open(tempdir / "stvrzenky.pdf", "rb") as pdffile: with open(tempdir / "stvrzenky.pdf", "rb") as pdffile:
response = HttpResponse(pdffile.read(), content_type='application/pdf') response = HttpResponse(pdffile.read(), content_type='application/pdf')
shutil.rmtree(tempdir)
return response return response

Loading…
Cancel
Save