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/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