Lepší složky i pro stvrzenky
This commit is contained in:
parent
213d3cc7b2
commit
88ae103ec1
1 changed files with 8 additions and 8 deletions
|
@ -79,14 +79,14 @@ def soustredeniStvrzenkyView(request, soustredeni):
|
|||
castka = Nastaveni.get_solo().cena_sous
|
||||
tex = render(request, 'soustredeni/stvrzenky.tex', {'ucastnici': ucastnici, 'soustredeni': soustredeni, 'castka': castka}).content
|
||||
|
||||
tempdir = Path(tempfile.mkdtemp())
|
||||
with open(tempdir / "stvrzenky.tex", "w") as texfile:
|
||||
texfile.write(tex.decode())
|
||||
with tempfile.TemporaryDirectory() as tempdirfn:
|
||||
tempdir = Path(tempdirfn)
|
||||
with open(tempdir / "stvrzenky.tex", "w") as texfile:
|
||||
texfile.write(tex.decode())
|
||||
|
||||
shutil.copy(find('images/logomm.pdf'), tempdir)
|
||||
subprocess.call(["pdflatex", "stvrzenky.tex"], cwd = tempdir, stdout=subprocess.DEVNULL)
|
||||
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)
|
||||
with open(tempdir / "stvrzenky.pdf", "rb") as pdffile:
|
||||
response = HttpResponse(pdffile.read(), content_type='application/pdf')
|
||||
return response
|
||||
|
|
Loading…
Reference in a new issue