From af734a045f401ad158395b05b166afc06a9de2b6 Mon Sep 17 00:00:00 2001 From: Leandro Roberto Silva Date: Thu, 14 Mar 2019 21:01:44 -0300 Subject: [PATCH] =?UTF-8?q?Revert=20"Adicionando=20gera=C3=A7=C3=A3o=20de?= =?UTF-8?q?=20pdf=20para=20texto=20articulado=20Fix=20#2192=20(#2607)"=20(?= =?UTF-8?q?#2614)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit bd0ba6b35c8e1792b56c571867a927ea869da8cb. --- sapl/relatorios/urls.py | 5 +- sapl/relatorios/views.py | 58 ------------------- sapl/static/sapl/css/header-relatorio.css | 46 --------------- sapl/static/sapl/css/relatorio.css | 56 ------------------ .../compilacao/textoarticulado_detail.html | 2 +- sapl/templates/relatorios/header.html | 31 ---------- .../templates/relatorios/relatorio_texto.html | 52 ----------------- 7 files changed, 2 insertions(+), 248 deletions(-) delete mode 100644 sapl/static/sapl/css/header-relatorio.css delete mode 100644 sapl/static/sapl/css/relatorio.css delete mode 100644 sapl/templates/relatorios/header.html delete mode 100644 sapl/templates/relatorios/relatorio_texto.html diff --git a/sapl/relatorios/urls.py b/sapl/relatorios/urls.py index 911763a09..e31f5dcab 100644 --- a/sapl/relatorios/urls.py +++ b/sapl/relatorios/urls.py @@ -5,8 +5,7 @@ from .views import (relatorio_capa_processo, relatorio_documento_administrativo, relatorio_espelho, relatorio_etiqueta_protocolo, relatorio_materia, relatorio_ordem_dia, relatorio_pauta_sessao, - relatorio_protocolo, relatorio_sessao_plenaria, - texto_articulado_pdf) + relatorio_protocolo, relatorio_sessao_plenaria) app_name = AppConfig.name @@ -29,6 +28,4 @@ urlpatterns = [ relatorio_etiqueta_protocolo, name='relatorio_etiqueta_protocolo'), url(r'^relatorios/pauta-sessao/(?P\d+)/$', relatorio_pauta_sessao, name='relatorio_pauta_sessao'), - url(r'^relatorios/texto_articulado/(?P\d+)/$', - texto_articulado_pdf, name='texto_articulado'), ] diff --git a/sapl/relatorios/views.py b/sapl/relatorios/views.py index 7d3a0c5c2..53331eadd 100755 --- a/sapl/relatorios/views.py +++ b/sapl/relatorios/views.py @@ -7,9 +7,7 @@ from django.core.exceptions import ObjectDoesNotExist from django.http import Http404, HttpResponse from django.utils import timezone 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.comissoes.models import Comissao 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_protocolo_gerar, pdf_sessao_plenaria_gerar) -from sapl.compilacao.models import TextoArticulado - -from weasyprint import HTML, CSS - def get_kwargs_params(request, fields): kwargs = {} @@ -1205,55 +1199,3 @@ def get_pauta_sessao(sessao, casa): return (lst_expediente_materia, lst_votacao, 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 \ No newline at end of file diff --git a/sapl/static/sapl/css/header-relatorio.css b/sapl/static/sapl/css/header-relatorio.css deleted file mode 100644 index ea24567c8..000000000 --- a/sapl/static/sapl/css/header-relatorio.css +++ /dev/null @@ -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; -} \ No newline at end of file diff --git a/sapl/static/sapl/css/relatorio.css b/sapl/static/sapl/css/relatorio.css deleted file mode 100644 index c3f2ec21f..000000000 --- a/sapl/static/sapl/css/relatorio.css +++ /dev/null @@ -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; -} \ No newline at end of file diff --git a/sapl/templates/compilacao/textoarticulado_detail.html b/sapl/templates/compilacao/textoarticulado_detail.html index 135f17bb1..9560a95f7 100644 --- a/sapl/templates/compilacao/textoarticulado_detail.html +++ b/sapl/templates/compilacao/textoarticulado_detail.html @@ -21,7 +21,7 @@ {% if perms.compilacao.lock_unlock_textoarticulado and not object.editable_only_by_owners%} {% if object.editing_locked %}{% trans 'Desbloquear Edição' %}{%else%}{% trans 'Publicar Texto' %}{% endif %} {% endif %} - Imprimir Texto + {% endblock actions %} diff --git a/sapl/templates/relatorios/header.html b/sapl/templates/relatorios/header.html deleted file mode 100644 index f18a0aa86..000000000 --- a/sapl/templates/relatorios/header.html +++ /dev/null @@ -1,31 +0,0 @@ -{% load common_tags %} -{% load render_bundle from webpack_loader %} -{% load webpack_static from webpack_loader %} -{% load static %} - - - - - - - - - - -
-
-
- -
-
-
    -
  • {{casa}}

  • -
  • Sistema de Apoio ao Processo Legislativo

  • -
-
-
-
-

- - - \ No newline at end of file diff --git a/sapl/templates/relatorios/relatorio_texto.html b/sapl/templates/relatorios/relatorio_texto.html deleted file mode 100644 index 664e7a6ae..000000000 --- a/sapl/templates/relatorios/relatorio_texto.html +++ /dev/null @@ -1,52 +0,0 @@ - -{% load common_tags %} -{% load static %} - - - - - - -

Texto Articulado: {{object}}

- -

Identificação Básica

-

Tipo de Texto Articulado: {{object.tipo_ta}}

-

Tipo da Norma Jurídica: {{object.content_object.tipo}}

-

Número: {{object.numero}}

-

Ano: {{object.ano}}

-

Data: {{object.data}}

- -

Ementa

-

{{object.ementa}}

- \ No newline at end of file