Browse Source

adicionadas normas por vigencia

pull/2429/head
Cesar Carvalho 7 years ago
parent
commit
bcd3cc7922
  1. 8
      sapl/base/forms.py
  2. 28
      sapl/base/views.py
  3. 32
      sapl/templates/base/RelatorioNormasVigencia_filter.html

8
sapl/base/forms.py

@ -733,8 +733,7 @@ class RelatorioNormasVigenciaFilterSet(django_filters.FilterSet):
ano = django_filters.ChoiceFilter(required=True, ano = django_filters.ChoiceFilter(required=True,
label='Ano da Norma', label='Ano da Norma',
choices=RANGE_ANOS, choices=RANGE_ANOS)
method='filter_vigencia')
vigencia = forms.ChoiceField( vigencia = forms.ChoiceField(
label=_('Vigência'), label=_('Vigência'),
@ -766,11 +765,6 @@ class RelatorioNormasVigenciaFilterSet(django_filters.FilterSet):
def qs(self): def qs(self):
return qs_override_django_filter(self) return qs_override_django_filter(self)
def filter_vigencia(self, qs, *args, **kwargs):
import ipdb; ipdb.set_trace()
parent = super(RelatorioNormasVigenciaFilterSet, self).qs
return parent.distinct().order_by('data')
class RelatorioPresencaSessaoFilterSet(django_filters.FilterSet): class RelatorioPresencaSessaoFilterSet(django_filters.FilterSet):

28
sapl/base/views.py

@ -1,6 +1,7 @@
import collections
import datetime
import logging import logging
import os import os
import collections
from django.contrib.auth import get_user_model from django.contrib.auth import get_user_model
from django.contrib.auth.mixins import PermissionRequiredMixin from django.contrib.auth.mixins import PermissionRequiredMixin
@ -785,12 +786,34 @@ class RelatorioNormasVigenciaView(FilterView):
filterset_class = RelatorioNormasVigenciaFilterSet filterset_class = RelatorioNormasVigenciaFilterSet
template_name = 'base/RelatorioNormasVigencia_filter.html' template_name = 'base/RelatorioNormasVigencia_filter.html'
def get_filterset_kwargs(self, filterset_class):
super(RelatorioNormasVigenciaView,
self).get_filterset_kwargs(filterset_class)
kwargs = {'data': self.request.GET or None}
qs = self.get_queryset().order_by('data').distinct()
if kwargs['data']:
ano = kwargs['data']['ano']
vigencia = kwargs['data']['vigencia']
qs = qs.filter(ano=ano)
if vigencia == 'True':
qs_dt_not_null = qs.filter(data_vigencia__isnull=True)
qs = (qs_dt_not_null | qs.filter(data_vigencia__gte=datetime.datetime.now().date())).distinct()
else:
qs = qs.filter(data_vigencia__lt=datetime.datetime.now().date())
kwargs.update({
'queryset': qs,
})
return kwargs
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super(RelatorioNormasVigenciaView, context = super(RelatorioNormasVigenciaView,
self).get_context_data(**kwargs) self).get_context_data(**kwargs)
context['title'] = _('Normas por vigência') context['title'] = _('Normas por vigência')
# import ipdb; ipdb.set_trace()
# Verifica se os campos foram preenchidos # Verifica se os campos foram preenchidos
if not self.filterset.form.is_valid(): if not self.filterset.form.is_valid():
return context return context
@ -800,6 +823,7 @@ class RelatorioNormasVigenciaView(FilterView):
context['show_results'] = show_results_filter_set(qr) context['show_results'] = show_results_filter_set(qr)
context['ano'] = self.request.GET['ano'] context['ano'] = self.request.GET['ano']
context['vigencia'] = 'Vigente' if self.request.GET['vigencia'] == 'True' else 'Não vigente'
return context return context

32
sapl/templates/base/RelatorioNormasVigencia_filter.html

@ -9,21 +9,14 @@
{% if show_results %} {% if show_results %}
<div class="actions btn-group pull-right" role="group"> <div class="actions btn-group pull-right" role="group">
<a href="{% url 'sapl.base:normas_por_mes' %}" class="btn btn-default">{% trans 'Fazer nova pesquisa' %}</a> <a href="{% url 'sapl.base:normas_por_vigencia' %}" class="btn btn-default">{% trans 'Fazer nova pesquisa' %}</a>
</div> </div>
<br /><br /><br /><br /> <br /><br /><br /><br />
<b>PARÂMETROS DE PESQUISA:<br /></b> <b>PARÂMETROS DE PESQUISA:<br /></b>
&emsp;Ano: {{ ano }} <br /> &emsp;Ano: {{ ano }} <br />
&emsp;Vigência: {{ vigencia }} <br />
{% if object_list %}
<br/> <br/>
{% for mes, normas in normas_mes.items %}
<div style="overflow:auto; ">
<table class="table table-bordered table-hover" style="margin-bottom: 0px;">
<thead class="thead-default">
<tr>
<th><h3 style="text-align:center;">Mês: {{ mes }}</h3></th>
</tr>
</thead>
</table>
<table class="table table-bordered table-hover" style="width:100%"> <table class="table table-bordered table-hover" style="width:100%">
<thead class="thead-default" > <thead class="thead-default" >
<tr class="active"> <tr class="active">
@ -32,17 +25,24 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% for n in normas %} {% for norma in object_list %}
<tr> <tr>
<td><a href="{% url 'sapl.norma:normajuridica_detail' n.pk %}"> <td><a href="{% url 'sapl.norma:normajuridica_detail' norma.pk %}">
{{n.tipo.descricao}} - {{n.tipo.sigla}} {{n.numero}}/{{n.ano}} {{norma.tipo.descricao}} - {{norma.tipo.sigla}} {{norma.numero}}/{{norma.ano}}
</a></td> </a></td>
<td>{{n.ementa}}<br>{{n.observacao}}</td> <td>{{norma.ementa}}<br>{{norma.observacao}}</td>
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
</div> {% else %}
{% endfor %} <table class="table table-bordered table-hover" style="margin-top:30px;">
<thead class="thead-default" >
<tr class="active">
<th> Não foi encontrada nenhuma norma com os parâmetros buscados.</th>
</tr>
</thead>
</table>
{% endif %}
{% endif %} {% endif %}
{% endblock base_content %} {% endblock base_content %}

Loading…
Cancel
Save