aboutsummaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorAndrea Lepori <alepori@student.ethz.ch>2020-08-29 14:21:01 +0200
committerAndrea Lepori <alepori@student.ethz.ch>2020-08-29 14:21:01 +0200
commit10e742446d962889e821a31306fc0388961fccb2 (patch)
tree8ad956ce4043a53291ff4bb0b37e0c9f527107bf /client
parentwait to render pdf for js to load (diff)
downloadscout-subs-10e742446d962889e821a31306fc0388961fccb2.tar.gz
scout-subs-10e742446d962889e821a31306fc0388961fccb2.zip
different response for pdf downloads
Diffstat (limited to 'client')
-rw-r--r--client/views.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/client/views.py b/client/views.py
index b1b8297..57747ee 100644
--- a/client/views.py
+++ b/client/views.py
@@ -49,9 +49,11 @@ def index(request):
context = {'doc': document}
html = template.render(context)
pdf = pdfkit.from_string(html, False)
- result = BytesIO(pdf)
- result.seek(0)
- return FileResponse(result, as_attachment=True, filename=document.document_type.name+".pdf")
+ # build response
+ filename = document.document_type.name + ".pdf"
+ response = HttpResponse(pdf, content_type='application/pdf')
+ response['Content-Disposition'] = 'attachment; filename="' + filename + '"'
+ return response
elif request.POST["action"][0] == 'a':
# sign autosign doc
if document.status == "autosign":