From e2abd871bda6e2c0ab0e78f938579ba8f44a2a25 Mon Sep 17 00:00:00 2001 From: Edward Ribeiro Date: Fri, 26 Jan 2018 16:21:26 -0200 Subject: [PATCH] =?UTF-8?q?HOT-FIX:=20modifica=20a=20forma=20como=20os=20P?= =?UTF-8?q?DFs=20gerados=20pelo=20weasyprint=20s=C3=A3o=20retornados=20via?= =?UTF-8?q?=20response?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sapl/materia/views.py | 12 +++++++----- sapl/norma/views.py | 11 +++++------ 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/sapl/materia/views.py b/sapl/materia/views.py index 78ff34716..bbf96e87e 100644 --- a/sapl/materia/views.py +++ b/sapl/materia/views.py @@ -1784,11 +1784,13 @@ class ImpressosView(PermissionRequiredMixin, TemplateView): def gerar_pdf_impressos(request, context, template_name): template = loader.get_template(template_name) html = template.render(RequestContext(request, context)) - response = HttpResponse(content_type="application/pdf") - weasyprint.HTML( - string=html, - base_url=request.build_absolute_uri()).write_pdf( - response) + + pdf = weasyprint.HTML(string=html, base_url=request.build_absolute_uri() + ).write_pdf() + + response = HttpResponse(pdf, content_type='application/pdf') + response['Content-Disposition'] = ( + 'inline; filename="relatorio_impressos.pdf"') return response diff --git a/sapl/norma/views.py b/sapl/norma/views.py index 983ebac93..1f7ea286a 100644 --- a/sapl/norma/views.py +++ b/sapl/norma/views.py @@ -233,13 +233,12 @@ class ImpressosView(PermissionRequiredMixin, TemplateView): def gerar_pdf_impressos(request, context, template_name): template = loader.get_template(template_name) html = template.render(RequestContext(request, context)) - response = HttpResponse(content_type="application/pdf") - weasyprint.HTML( - string=html, - base_url=request.build_absolute_uri()).write_pdf( - response) + pdf = weasyprint.HTML(string=html, base_url=request.build_absolute_uri() + ).write_pdf() - return response + response = HttpResponse(pdf, content_type='application/pdf') + response['Content-Disposition'] = ( + 'inline; filename="relatorio_impressos.pdf"') class NormaPesquisaSimplesView(PermissionRequiredMixin, FormView): form_class = NormaPesquisaSimplesForm