Browse Source

Melhorando visualização do documento de extrato da reunião

pull/2539/head
ulyssesBML 7 years ago
committed by VictorFabreF
parent
commit
a4bdfed209
  1. 15
      sapl/relatorios/views.py
  2. 20
      sapl/static/sapl/css/header-relatorio.css
  3. 2
      sapl/static/sapl/css/relatorio.css
  4. 11
      sapl/templates/relatorios/header_ata.html
  5. 3
      sapl/templates/relatorios/relatorio_ata.html

15
sapl/relatorios/views.py

@ -10,6 +10,7 @@ from django.utils import timezone
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from django.template.loader import render_to_string from django.template.loader import render_to_string
from sapl.settings import MEDIA_URL
from sapl.base.models import Autor, CasaLegislativa from sapl.base.models import Autor, CasaLegislativa
from sapl.comissoes.models import Comissao from sapl.comissoes.models import Comissao
from sapl.materia.models import (Autoria, MateriaLegislativa, Numeracao, from sapl.materia.models import (Autoria, MateriaLegislativa, Numeracao,
@ -1222,7 +1223,7 @@ def make_pdf(base_url,main_template,header_template,main_css='',header_css=''):
# Template of header # Template of header
html = HTML(base_url=base_url,string=header_template) html = HTML(base_url=base_url,string=header_template)
header = html.render(stylesheets=[CSS(string='div {position: fixed; top: 0cm; left: 0cm;}')]) header = html.render(stylesheets=[CSS(string='@page {size:A4; margin:1cm;}')])
header_page = header.pages[0] header_page = header.pages[0]
header_body = get_page_body(header_page._page_box.all_children()) header_body = get_page_body(header_page._page_box.all_children())
@ -1256,21 +1257,19 @@ def resumo_ata_pdf(request,pk):
context.update(get_oradores_explicações_pessoais(sessao_plenaria)) context.update(get_oradores_explicações_pessoais(sessao_plenaria))
context.update(get_ocorrencias_da_sessão(sessao_plenaria)) context.update(get_ocorrencias_da_sessão(sessao_plenaria))
context.update({'object':sessao_plenaria}) context.update({'object':sessao_plenaria})
context.update({"data": dt.today().strftime('%d/%m/%Y')}) context.update({'data': dt.today().strftime('%d/%m/%Y')})
context.update({'rodape':rodape}) context.update({'rodape':rodape})
header_context = {"casa":casa, 'logotipo':casa.logotipo, 'MEDIA_URL': MEDIA_URL}
html_template = render_to_string('relatorios/relatorio_ata.html',context) html_template = render_to_string('relatorios/relatorio_ata.html',context)
html_header = render_to_string('relatorios/header_ata.html',{"casa":casa}) html_header = render_to_string('relatorios/header_ata.html', header_context)
pdf_file = make_pdf(base_url=base_url,main_template=html_template,header_template=html_header) pdf_file = make_pdf(base_url=base_url,main_template=html_template,header_template=html_header)
response = HttpResponse(content_type='application/pdf;') response = HttpResponse(content_type='application/pdf;')
response['Content-Disposition'] = 'inline; filename=relatorio.pdf' response['Content-Disposition'] = 'inline; filename=relatorio.pdf'
response['Content-Transfer-Encoding'] = 'binary' response['Content-Transfer-Encoding'] = 'binary'
with tempfile.NamedTemporaryFile(delete=True) as output: response.write(pdf_file)
output.write(pdf_file)
output.flush()
output = open(output.name, 'rb')
response.write(output.read())
return response return response

20
sapl/static/sapl/css/header-relatorio.css

@ -3,6 +3,7 @@ html body p {
text-align: center; text-align: center;
font-size: 11pt; font-size: 11pt;
padding: 5px; padding: 5px;
margin-top: -15px;
} }
html body section { html body section {
box-sizing: border-box; box-sizing: border-box;
@ -22,9 +23,24 @@ html body section dd {
} }
html body section dd ul li { html body section dd ul li {
list-style-type: none; list-style-type: none;
margin-left: 50px; margin-left: 90px;
margin-bottom: -15px;
}
h2 {
font-size: 14pt;
} }
h3 { h3 {
font-size: 12pt; font-size: 10pt;
color: #6e6e6e; color: #6e6e6e;
} }
ul {
padding: 0;
list-style: none;
margin-top:10px;
}
html body section dt img {
max-width:80px;
margin-left: 20px;
}

2
sapl/static/sapl/css/relatorio.css

@ -1,5 +1,5 @@
@page{ @page{
margin-top: 8cm; margin-top: 4.5cm;
size: A4 portrait; size: A4 portrait;
} }

11
sapl/templates/relatorios/header_ata.html

@ -1,3 +1,6 @@
{% load common_tags %}
{% load render_bundle from webpack_loader %}
{% load webpack_static from webpack_loader %}
{% load static %} {% load static %}
<!DOCTYPE html> <!DOCTYPE html>
<meta charset="utf-8"> <meta charset="utf-8">
@ -10,23 +13,19 @@
<body> <body>
<section id="informations"> <section id="informations">
<dl> <dl>
<dt class="image-header"> <dt class="image-header">
<img src="{% static '/sapl/img/logo.png' %}" <img src="{% if logotipo %}{{ MEDIA_URL }}{{ logotipo }}{% else %}{% webpack_static 'img/logo.png' %}{% endif %}">
alt="Logo" >
</dt> </dt>
<dd class="title"> <dd class="title">
<ul> <ul>
<li><h1>{{casa}}</h1></li> <li style="margin-top:10px"><h2>{{casa}}</h2></li>
<li><h3>Sistema de Apoio ao Processo Legislativo</h3></li> <li><h3>Sistema de Apoio ao Processo Legislativo</h3></li>
<li><h4></h4></li>
</ul> </ul>
</dd> </dd>
</dl> </dl>
</section> </section>
<p></p> <p></p>
</body> </body>
</html> </html>

3
sapl/templates/relatorios/relatorio_ata.html

@ -48,8 +48,7 @@
{% include 'sessao/blocos_ata/materias_ordem_dia.html' %} {% include 'sessao/blocos_ata/materias_ordem_dia.html' %}
{% include 'sessao/blocos_ata/oradores_explicacoes.html' %} {% include 'sessao/blocos_ata/oradores_explicacoes.html' %}
<div style="padding:5px;margin-top:80px;border-top: 1px solid black;">
<div style="page-break-before:always;">
<legend >{{texto_assinatura}}</legend> <legend >{{texto_assinatura}}</legend>

Loading…
Cancel
Save