Browse Source

Revert "Adicionando geração de pdf para texto articulado Fix #2192 (#2607)" (#2614)

This reverts commit bd0ba6b35c.
pull/2615/head
Leandro Roberto Silva 6 years ago
committed by GitHub
parent
commit
af734a045f
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      sapl/relatorios/urls.py
  2. 58
      sapl/relatorios/views.py
  3. 46
      sapl/static/sapl/css/header-relatorio.css
  4. 56
      sapl/static/sapl/css/relatorio.css
  5. 2
      sapl/templates/compilacao/textoarticulado_detail.html
  6. 31
      sapl/templates/relatorios/header.html
  7. 52
      sapl/templates/relatorios/relatorio_texto.html

5
sapl/relatorios/urls.py

@ -5,8 +5,7 @@ from .views import (relatorio_capa_processo,
relatorio_documento_administrativo, relatorio_espelho, relatorio_documento_administrativo, relatorio_espelho,
relatorio_etiqueta_protocolo, relatorio_materia, relatorio_etiqueta_protocolo, relatorio_materia,
relatorio_ordem_dia, relatorio_pauta_sessao, relatorio_ordem_dia, relatorio_pauta_sessao,
relatorio_protocolo, relatorio_sessao_plenaria, relatorio_protocolo, relatorio_sessao_plenaria)
texto_articulado_pdf)
app_name = AppConfig.name app_name = AppConfig.name
@ -29,6 +28,4 @@ urlpatterns = [
relatorio_etiqueta_protocolo, name='relatorio_etiqueta_protocolo'), relatorio_etiqueta_protocolo, name='relatorio_etiqueta_protocolo'),
url(r'^relatorios/pauta-sessao/(?P<pk>\d+)/$', url(r'^relatorios/pauta-sessao/(?P<pk>\d+)/$',
relatorio_pauta_sessao, name='relatorio_pauta_sessao'), relatorio_pauta_sessao, name='relatorio_pauta_sessao'),
url(r'^relatorios/texto_articulado/(?P<pk>\d+)/$',
texto_articulado_pdf, name='texto_articulado'),
] ]

58
sapl/relatorios/views.py

@ -7,9 +7,7 @@ from django.core.exceptions import ObjectDoesNotExist
from django.http import Http404, HttpResponse from django.http import Http404, HttpResponse
from django.utils import timezone 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 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,
@ -32,10 +30,6 @@ from .templates import (pdf_capa_processo_gerar,
pdf_ordem_dia_gerar, pdf_pauta_sessao_gerar, pdf_ordem_dia_gerar, pdf_pauta_sessao_gerar,
pdf_protocolo_gerar, pdf_sessao_plenaria_gerar) pdf_protocolo_gerar, pdf_sessao_plenaria_gerar)
from sapl.compilacao.models import TextoArticulado
from weasyprint import HTML, CSS
def get_kwargs_params(request, fields): def get_kwargs_params(request, fields):
kwargs = {} kwargs = {}
@ -1205,55 +1199,3 @@ def get_pauta_sessao(sessao, casa):
return (lst_expediente_materia, return (lst_expediente_materia,
lst_votacao, lst_votacao,
inf_basicas_dic) inf_basicas_dic)
def make_pdf(base_url,main_template,header_template,main_css='',header_css=''):
html = HTML(base_url=base_url, string=main_template)
main_doc = html.render(stylesheets=[])
def get_page_body(boxes):
for box in boxes:
if box.element_tag == 'body':
return box
return get_page_body(box.all_children())
# Template of header
html = HTML(base_url=base_url,string=header_template)
header = html.render(stylesheets=[CSS(string='@page {size:A4; margin:1cm;}')])
header_page = header.pages[0]
header_body = get_page_body(header_page._page_box.all_children())
header_body = header_body.copy_with_children(header_body.all_children())
for page in main_doc.pages:
page_body = get_page_body(page._page_box.all_children())
page_body.children += header_body.all_children()
pdf_file = main_doc.write_pdf()
return pdf_file
def texto_articulado_pdf(request,pk):
texto_articulado = TextoArticulado.objects.get(pk=pk)
base_url = request.build_absolute_uri()
casa = CasaLegislativa.objects.first()
rodape = ' '.join(get_rodape(casa))
context = {
'object': texto_articulado,
'rodape': rodape,
'data': dt.today().strftime('%d/%m/%Y')
}
html_template = render_to_string('relatorios/relatorio_texto.html',context)
header_context = {"casa":casa, 'logotipo':casa.logotipo, 'MEDIA_URL': MEDIA_URL}
html_header = render_to_string('relatorios/header.html', header_context)
pdf_file = make_pdf(base_url=base_url,main_template=html_template,header_template=html_header)
response = HttpResponse(content_type='application/pdf;')
response['Content-Disposition'] = 'inline; filename=relatorio.pdf'
response['Content-Transfer-Encoding'] = 'binary'
response.write(pdf_file)
return response

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

@ -1,46 +0,0 @@
html body p {
border-top: 1px solid black;
text-align: center;
font-size: 11pt;
padding: 5px;
margin-top: -15px;
}
html body section {
box-sizing: border-box;
}
html body section dl {
display: flex;
flex-wrap: wrap;
rows: 2;
columns: 2;
}
html body section dt{
width: 50px;
}
html body section dd {
max-width:550px;
text-align: center;
}
html body section dd ul li {
list-style-type: none;
margin-left: 90px;
margin-bottom: -15px;
}
h2 {
font-size: 14pt;
}
h3 {
font-size: 10pt;
color: #6e6e6e;
}
ul {
padding: 0;
list-style: none;
margin-top:10px;
}
html body section dt img {
max-width:80px;
margin-left: 20px;
}

56
sapl/static/sapl/css/relatorio.css

@ -1,56 +0,0 @@
@page{
margin-top: 4.5cm;
size: A4 portrait;
}
h2.gray-title{
color: gray;
font-size: 14pt;
break-after: avoid-page;
page-break-after: avoid;
}
h3 {
font-size: 10pt;
break-after: avoid-page;
page-break-after: avoid;
}
p {
font-size: 10pt;
text-align: justify;
text-justify: inter-word;
}
fieldset {
border: 0;
}
html body section {
box-sizing: border-box;
}
html body section dl {
display: flex;
flex-wrap: wrap;
columns: 5;
}
html body section dt{
width: 50px;
}
html body section dd {
text-align: center;
}
html body section dd ul li {
list-style-type: none;
margin-left: 50px;
}
fieldset {
page-break-after: avoid;
margin:5px;
padding:0px;
}

2
sapl/templates/compilacao/textoarticulado_detail.html

@ -21,7 +21,7 @@
{% if perms.compilacao.lock_unlock_textoarticulado and not object.editable_only_by_owners%} {% if perms.compilacao.lock_unlock_textoarticulado and not object.editable_only_by_owners%}
<a href="{% url 'sapl.compilacao:ta_text_edit' object.pk %}?{% if object.editing_locked %}unlock{%else%}lock{% endif %}" class="btn {% if object.editing_locked %}btn-outline-danger{%else%}btn-outline-primary{% endif %}">{% if object.editing_locked %}{% trans 'Desbloquear Edição' %}{%else%}{% trans 'Publicar Texto' %}{% endif %}</a> <a href="{% url 'sapl.compilacao:ta_text_edit' object.pk %}?{% if object.editing_locked %}unlock{%else%}lock{% endif %}" class="btn {% if object.editing_locked %}btn-outline-danger{%else%}btn-outline-primary{% endif %}">{% if object.editing_locked %}{% trans 'Desbloquear Edição' %}{%else%}{% trans 'Publicar Texto' %}{% endif %}</a>
{% endif %} {% endif %}
<a href="{% url 'sapl.relatorios:texto_articulado' object.pk %}" class="btn btn-outline-primary">Imprimir Texto</a>
</div> </div>
</div> </div>
{% endblock actions %} {% endblock actions %}

31
sapl/templates/relatorios/header.html

@ -1,31 +0,0 @@
{% load common_tags %}
{% load render_bundle from webpack_loader %}
{% load webpack_static from webpack_loader %}
{% load static %}
<!DOCTYPE html>
<meta charset="utf-8">
</meta>
<html lang="pt-br">
<head>
<link rel="stylesheet" href="{% static 'sapl/css/header-relatorio.css'%}">
</head>
<body>
<section id="informations">
<dl>
<dt class="image-header">
<img src="{% if logotipo %}{{ MEDIA_URL }}{{ logotipo }}{% else %}{% webpack_static 'img/logo.png' %}{% endif %}">
</dt>
<dd class="title">
<ul>
<li style="margin-top:10px"><h2>{{casa}}</h2></li>
<li><h3>Sistema de Apoio ao Processo Legislativo</h3></li>
</ul>
</dd>
</dl>
</section>
<p></p>
</body>
</html>

52
sapl/templates/relatorios/relatorio_texto.html

@ -1,52 +0,0 @@
{% load common_tags %}
{% load static %}
<head>
<style>
@page{
@bottom-right {
content: "Página" counter(page);
height: 3cm;
font-size: 8pt;
}
@bottom-center {
border-top: 1px solid black;
font-size: 8pt;
height: 1cm;
content: "{{rodape|safe}}";
font-style:italic;
}
@bottom-left {
content: "{{data}}";
height: 3cm;
font-size: 8pt;
}
@top-center {
content: string(title);
}
header {
width: 0;
height: 0;
visibility: hidden;
string-set: title content();
}
}
</style>
<link rel="stylesheet" href="{% static '/sapl/css/relatorio.css'%}">
</head>
<body>
<h3 style="text-align:center;">Texto Articulado: {{object}}</h3>
<h3 style="color:gray;">Identificação Básica</h3>
<p style="font-size: 8pt"><b>Tipo de Texto Articulado:</b> {{object.tipo_ta}}</p>
<p style="font-size: 8pt"><b>Tipo da Norma Jurídica:</b> {{object.content_object.tipo}}</p>
<p style="font-size: 8pt"><b>Número:</b> {{object.numero}}</p>
<p style="font-size: 8pt"><b>Ano:</b> {{object.ano}}</p>
<p style="font-size: 8pt"><b>Data:</b> {{object.data}}</p>
<h3 style="color:gray;margin-top:50px;">Ementa</h3>
<p>{{object.ementa}}</p>
</body>
Loading…
Cancel
Save