Browse Source

HOT-FIX: modifica a forma como os PDFs gerados pelo weasyprint são retornados via response

pull/1681/head
Edward Ribeiro 7 years ago
parent
commit
e2abd871bd
  1. 12
      sapl/materia/views.py
  2. 11
      sapl/norma/views.py

12
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

11
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

Loading…
Cancel
Save