Browse Source

Revert "cria impresso de indice de normas (#1625)"

This reverts commit bf6e60d23b.
pull/1634/head
Edward Ribeiro 7 years ago
parent
commit
4a8d00917c
  1. 5
      sapl/materia/urls.py
  2. 58
      sapl/norma/forms.py
  3. 57
      sapl/norma/views.py
  4. 10
      sapl/templates/materia/impressos/impressos.html
  5. 41
      sapl/templates/materia/impressos/normas_pdf.html

5
sapl/materia/urls.py

@ -25,8 +25,6 @@ from sapl.materia.views import (AcompanhamentoConfirmarView,
TramitacaoEmLoteView, UnidadeTramitacaoCrud, TramitacaoEmLoteView, UnidadeTramitacaoCrud,
proposicao_texto, recuperar_materia) proposicao_texto, recuperar_materia)
from sapl.norma.views import NormaPesquisaView
from .apps import AppConfig from .apps import AppConfig
app_name = AppConfig.name app_name = AppConfig.name
@ -44,9 +42,6 @@ urlpatterns_impressos = [
url(r'^materia/impressos/ficha-seleciona/$', url(r'^materia/impressos/ficha-seleciona/$',
FichaSelecionaView.as_view(), FichaSelecionaView.as_view(),
name='impressos_ficha_seleciona'), name='impressos_ficha_seleciona'),
url(r'^materia/impressos/norma-pesquisa/$',
NormaPesquisaView.as_view(),
name='impressos_norma_pesquisa'),
] ]
urlpatterns_materia = [ urlpatterns_materia = [

58
sapl/norma/forms.py

@ -208,61 +208,3 @@ class NormaRelacionadaForm(ModelForm):
relacionada.norma_relacionada = self.cleaned_data['norma_relacionada'] relacionada.norma_relacionada = self.cleaned_data['norma_relacionada']
relacionada.save() relacionada.save()
return relacionada 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

57
sapl/norma/views.py

@ -6,13 +6,6 @@ from django.utils import timezone
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from django.views.generic.base import RedirectView from django.views.generic.base import RedirectView
from django_filters.views import FilterView 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.base.models import AppConfig
from sapl.compilacao.views import IntegracaoTaView from sapl.compilacao.views import IntegracaoTaView
@ -20,7 +13,7 @@ from sapl.crud.base import (RP_DETAIL, RP_LIST, Crud, CrudAux,
MasterDetailCrud, make_pagination) MasterDetailCrud, make_pagination)
from sapl.utils import show_results_filter_set 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, from .models import (AssuntoNorma, NormaJuridica, NormaRelacionada,
TipoNormaJuridica, TipoVinculoNormaJuridica) TipoNormaJuridica, TipoVinculoNormaJuridica)
@ -223,51 +216,3 @@ def recuperar_numero_norma(request):
{'numero': 1, 'ano': ano}) {'numero': 1, 'ano': ano})
return response 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)

10
sapl/templates/materia/impressos/impressos.html

@ -10,23 +10,15 @@
<h1 class="page-header">Impressos</h1> <h1 class="page-header">Impressos</h1>
</br>
<h2 class="legend">Etiqueta</h2> <h2 class="legend">Etiqueta</h2>
<ul> <ul>
<li><a href="{% url 'sapl.materia:impressos_etiqueta' %}">Pesquisar</a></li> <li><a href="{% url 'sapl.materia:impressos_etiqueta' %}">Pesquisar</a></li>
</ul> </ul>
</br> <h2 class="legend">Ficha</h2>
<h2 class="legend">Capa Processo</h2>
<ul> <ul>
<li><a href="{% url 'sapl.materia:impressos_ficha_pesquisa' %}">Pesquisar</a></li> <li><a href="{% url 'sapl.materia:impressos_ficha_pesquisa' %}">Pesquisar</a></li>
</ul> </ul>
</br>
<h2 class="legend">Índice de Normas Jurídicas</h2>
<ul>
<li><a href="{% url 'sapl.materia:impressos_norma_pesquisa' %}">Pesquisar</a></li>
</ul>
{#<h2 class="legend">Guia de Remessa</h2>#} {#<h2 class="legend">Guia de Remessa</h2>#}
{# <ul>#} {# <ul>#}

41
sapl/templates/materia/impressos/normas_pdf.html

@ -1,41 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Impressos</title>
<meta charset="utf-8">
</head>
<style type="text/css">
.text_pdf{
font-family: arial;
font-size: 70%;
}
</style>
<body style="margin-left:10px;margin-right:-50px; margin-top: -50px; text-align: justify">
{% if quantidade > 30 %}
<b><p class="alert_message">Sua pesquisa retornou mais do que 2000 impressos.</p><p class="alert_message">Por questões de performance, foram retornados apenas os 2000 primeiros.</p></b>
</br></br></br>
{% endif %}
{% for m in normas %}
<table>
<tr>
<td style="width:200px; vertical-align:top;"><span class="text_pdf"> {{m.tipo}} nº </span><span class="text_pdf"> {{m.numero}}, de {{m.data|date:"d/m/Y" }} </span>
</td>
<td>
</td>
<td style="width:450px; vertical-align:top;"><span class="text_pdf">{{m.ementa}}</span>
</td>
</tr>
</table>
</br>
{% endfor %}
</body>
Loading…
Cancel
Save