From 4a8d00917cd867ddd45d97137fde90f40cdc0750 Mon Sep 17 00:00:00 2001 From: Edward Ribeiro Date: Thu, 7 Dec 2017 14:02:07 -0200 Subject: [PATCH] Revert "cria impresso de indice de normas (#1625)" This reverts commit bf6e60d23bdf463e5034d03fa1bea7a0dce72795. --- sapl/materia/urls.py | 5 -- sapl/norma/forms.py | 58 ------------------- sapl/norma/views.py | 57 +----------------- .../materia/impressos/impressos.html | 10 +--- .../materia/impressos/normas_pdf.html | 41 ------------- 5 files changed, 2 insertions(+), 169 deletions(-) delete mode 100644 sapl/templates/materia/impressos/normas_pdf.html diff --git a/sapl/materia/urls.py b/sapl/materia/urls.py index 44051342f..b6a87cd5f 100644 --- a/sapl/materia/urls.py +++ b/sapl/materia/urls.py @@ -25,8 +25,6 @@ from sapl.materia.views import (AcompanhamentoConfirmarView, TramitacaoEmLoteView, UnidadeTramitacaoCrud, proposicao_texto, recuperar_materia) -from sapl.norma.views import NormaPesquisaView - from .apps import AppConfig app_name = AppConfig.name @@ -44,9 +42,6 @@ urlpatterns_impressos = [ url(r'^materia/impressos/ficha-seleciona/$', FichaSelecionaView.as_view(), name='impressos_ficha_seleciona'), - url(r'^materia/impressos/norma-pesquisa/$', - NormaPesquisaView.as_view(), - name='impressos_norma_pesquisa'), ] urlpatterns_materia = [ diff --git a/sapl/norma/forms.py b/sapl/norma/forms.py index c21650513..fa849171a 100644 --- a/sapl/norma/forms.py +++ b/sapl/norma/forms.py @@ -208,61 +208,3 @@ class NormaRelacionadaForm(ModelForm): relacionada.norma_relacionada = self.cleaned_data['norma_relacionada'] relacionada.save() return relacionada - -class NormaPesquisaForm(forms.Form): - tipo_norma = forms.ModelChoiceField( - label=TipoNormaJuridica._meta.verbose_name, - queryset=TipoNormaJuridica.objects.all(), - required=False, - empty_label='Selecione') - - data_inicial = forms.DateField( - label='Data Inicial', - required=False, - widget=forms.DateInput(format='%d/%m/%Y') - ) - - data_final = forms.DateField( - label='Data Final', - required=False, - widget=forms.DateInput(format='%d/%m/%Y') - ) - - def __init__(self, *args, **kwargs): - super(NormaPesquisaForm, self).__init__(*args, **kwargs) - - row1 = to_row( - [('tipo_norma', 6), - ('data_inicial', 3), - ('data_final', 3)]) - - self.helper = FormHelper() - self.helper.layout = Layout( - Fieldset( - ('Índice de Normas'), - row1, - form_actions(label='Pesquisar') - ) - ) - - def clean(self): - super(NormaPesquisaForm, self).clean() - cleaned_data = self.cleaned_data - - data_inicial = cleaned_data['data_inicial'] - data_final = cleaned_data['data_final'] - - if (data_inicial and data_final and - data_inicial > data_final): - raise ValidationError(_( - 'A Data Final não pode ser menor que a Data Inicial')) - else: - condicao1 = data_inicial and not data_final - condicao2 = not data_inicial and data_final - if condicao1 or condicao2: - raise ValidationError(_('Caso pesquise por data, os campos de Data Inicial e ' + - 'Data Final devem ser preenchidos obrigatoriamente')) - - - return cleaned_data - diff --git a/sapl/norma/views.py b/sapl/norma/views.py index 8cf8469d2..f7ee34baf 100644 --- a/sapl/norma/views.py +++ b/sapl/norma/views.py @@ -6,13 +6,6 @@ from django.utils import timezone from django.utils.translation import ugettext_lazy as _ from django.views.generic.base import RedirectView from django_filters.views import FilterView -from django.contrib.auth.mixins import PermissionRequiredMixin - -from django.http import HttpResponse, JsonResponse -from django.views.generic.edit import FormView -from django.views.generic import CreateView, ListView, TemplateView, UpdateView -from django.template import RequestContext, loader -import weasyprint from sapl.base.models import AppConfig from sapl.compilacao.views import IntegracaoTaView @@ -20,7 +13,7 @@ from sapl.crud.base import (RP_DETAIL, RP_LIST, Crud, CrudAux, MasterDetailCrud, make_pagination) from sapl.utils import show_results_filter_set -from .forms import NormaFilterSet, NormaJuridicaForm, NormaRelacionadaForm, NormaPesquisaForm +from .forms import NormaFilterSet, NormaJuridicaForm, NormaRelacionadaForm from .models import (AssuntoNorma, NormaJuridica, NormaRelacionada, TipoNormaJuridica, TipoVinculoNormaJuridica) @@ -223,51 +216,3 @@ def recuperar_numero_norma(request): {'numero': 1, 'ano': ano}) return response - - -class ImpressosView(PermissionRequiredMixin, TemplateView): - template_name = 'materia/impressos/impressos.html' - permission_required = ('materia.can_access_impressos', ) - - -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) - - return response - -class NormaPesquisaView(PermissionRequiredMixin, FormView): - form_class = NormaPesquisaForm - template_name = 'materia/impressos/norma.html' - permission_required = ('materia.can_access_impressos', ) - - - def form_valid(self, form): - context = {} - - normas = NormaJuridica.objects.all().order_by( - '-numero') - template_norma = 'materia/impressos/normas_pdf.html' - - if form.cleaned_data['tipo_norma']: - normas = normas.filter(tipo=form.cleaned_data['tipo_norma']) - - if form.cleaned_data['data_inicial']: - normas = normas.filter( - data__gte=form.cleaned_data['data_inicial'], - data__lte=form.cleaned_data['data_final']) - - - context['quantidade'] = len(normas) - - if context['quantidade'] > 2000: - normas = normas[:2000] - - context['normas'] = normas - - return gerar_pdf_impressos(self.request, context, template_norma) diff --git a/sapl/templates/materia/impressos/impressos.html b/sapl/templates/materia/impressos/impressos.html index 71f9f6f6f..beb92862c 100644 --- a/sapl/templates/materia/impressos/impressos.html +++ b/sapl/templates/materia/impressos/impressos.html @@ -10,23 +10,15 @@

Impressos

-

Etiqueta

-
-

Capa Processo

+

Ficha

-
-

Índice de Normas Jurídicas

- - {#

Guia de Remessa

#} {#