Browse Source

normas por mes concluida e inicio normas vigencia

pull/2429/head
Cesar Carvalho 7 years ago
parent
commit
9a90c214dd
  1. 52
      sapl/base/forms.py
  2. 7
      sapl/base/urls.py
  3. 47
      sapl/base/views.py
  4. 28
      sapl/templates/base/RelatorioNormaMes_filter.html
  5. 48
      sapl/templates/base/RelatorioNormasVigencia_filter.html
  6. 8
      sapl/templates/base/relatorios_list.html

52
sapl/base/forms.py

@ -729,6 +729,58 @@ class RelatorioNormasMesFilterSet(django_filters.FilterSet):
return parent.distinct().order_by('data')
class RelatorioNormasVigenciaFilterSet(django_filters.FilterSet):
ano = django_filters.ChoiceFilter(required=True,
label='Ano da Norma',
choices=RANGE_ANOS)
vigencia = forms.ChoiceField(
label=_('Vigente'),
choices=[(True, "Vigente"), (False, "Não vigente")],
widget=forms.RadioSelect(),
required=True,
help_text=_('Se vc está trocando ou removendo o usuário deste Autor, '
'como o Sistema deve proceder com o usuário que está sendo'
' desvinculado?'))
# filter_overrides = {models.DateField: {
# 'filter_class': django_filters.DateFromToRangeFilter,
# 'extra': lambda f: {
# 'label': '%s (%s)' % (f.verbose_name, _('Ano')),
# 'widget': RangeWidgetOverride}
# }}
@property
def qs(self):
parent = super(RelatorioNormasVigenciaFilterSet, self).qs
return parent.distinct().order_by('data')
class Meta:
model = NormaJuridica
# fields = ['ano', 'vigencia']
def __init__(self, *args, **kwargs):
super(RelatorioNormasVigenciaFilterSet, self).__init__(
*args, **kwargs)
self.filters['ano'].label = 'Ano'
# self.filters['vigencia'].label = 'Vigência'
self.form.fields['ano'].required = True
# self.form.fields['vigencia'].required = True
row1 = to_row([('ano', 12)])
# row2 = to_row([('vigencia', 12)])
self.form.helper = FormHelper()
self.form.helper.form_method = 'GET'
self.form.helper.layout = Layout(
Fieldset(_('Normas por vigência.'),
row1,
form_actions(label='Pesquisar'))
)
class RelatorioPresencaSessaoFilterSet(django_filters.FilterSet):
filter_overrides = {models.DateField: {

7
sapl/base/urls.py

@ -24,7 +24,8 @@ from .views import (AlterarSenha, AppConfigCrud, CasaLegislativaCrud,
RelatorioMateriasTramitacaoView,
RelatorioPresencaSessaoView,
RelatorioReuniaoView, SaplSearchView,
RelatorioAtosPublicadosMesView)
RelatorioNormasPublicadasMesView,
RelatorioNormasVigenciaView)
app_name = AppConfig.name
@ -90,7 +91,9 @@ urlpatterns = [
url(r'^sistema/relatorios/materia-por-autor$',
RelatorioMateriasPorAutorView.as_view(), name='materia_por_autor'),
url(r'^sistema/relatorios/relatorio-por-mes$',
RelatorioAtosPublicadosMesView.as_view(), name='atos_por_mes'),
RelatorioNormasPublicadasMesView.as_view(), name='normas_por_mes'),
url(r'^sistema/relatorios/relatorio-por-vigencia$',
RelatorioNormasVigenciaView.as_view(), name='normas_por_vigencia'),
url(r'^sistema/relatorios/materia-por-ano-autor-tipo$',
RelatorioMateriasPorAnoAutorTipoView.as_view(),
name='materia_por_ano_autor_tipo'),

47
sapl/base/views.py

@ -1,5 +1,6 @@
import logging
import os
import collections
from django.contrib.auth import get_user_model
from django.contrib.auth.mixins import PermissionRequiredMixin
@ -46,7 +47,8 @@ from .forms import (AlterarSenhaForm, CasaLegislativaForm,
RelatorioMateriasTramitacaoilterSet,
RelatorioPresencaSessaoFilterSet,
RelatorioReuniaoFilterSet, UsuarioCreateForm,
UsuarioEditForm, RelatorioNormasMesFilterSet)
UsuarioEditForm, RelatorioNormasMesFilterSet,
RelatorioNormasVigenciaFilterSet)
from .models import AppConfig, CasaLegislativa
@ -745,13 +747,13 @@ class RelatorioMateriasPorAutorView(FilterView):
return context
class RelatorioAtosPublicadosMesView(FilterView):
class RelatorioNormasPublicadasMesView(FilterView):
model = NormaJuridica
filterset_class = RelatorioNormasMesFilterSet
template_name = 'base/RelatorioNormaMes_filter.html'
def get_context_data(self, **kwargs):
context = super(RelatorioAtosPublicadosMesView,
context = super(RelatorioNormasPublicadasMesView,
self).get_context_data(**kwargs)
context['title'] = _('Normas')
@ -765,19 +767,44 @@ class RelatorioAtosPublicadosMesView(FilterView):
context['show_results'] = show_results_filter_set(qr)
context['ano'] = self.request.GET['ano']
normas_mes = {}
normas_mes = collections.OrderedDict()
meses = {1: 'Janeiro', 2: 'Fevereiro', 3:'Março', 4: 'Abril', 5: 'Maio', 6:'Junho',
7: 'Julho', 8: 'Agosto', 9:'Setembro', 10:'Outubro', 11:'Novembro', 12:'Dezembro'}
for norma in context['object_list']:
if not meses[norma.data.month] in normas_mes:
normas_mes[meses[norma.data.month]] = []
normas_mes[meses[norma.data.month]].append(norma)
# for norma in context['object_list']:
# import ipdb; ipdb.set_trace()
# pass
context['normas_mes'] = normas_mes
return context
class RelatorioNormasVigenciaView(FilterView):
model = NormaJuridica
filterset_class = RelatorioNormasVigenciaFilterSet
template_name = 'base/RelatorioNormasVigencia_filter.html'
def get_context_data(self, **kwargs):
context = super(RelatorioNormasVigenciaView,
self).get_context_data(**kwargs)
context['title'] = _('Normas por vigência')
# Verifica se os campos foram preenchidos
if not self.filterset.form.is_valid():
return context
qr = self.request.GET.copy()
context['filter_url'] = ('&' + qr.urlencode()) if len(qr) > 0 else ''
# context['periodo'] = (
# self.request.GET['data_inicio_0'] +
# ' - ' + self.request.GET['data_inicio_1'])
context['show_results'] = show_results_filter_set(qr)
context['ano'] = self.request.GET['ano']
# import ipdb; ipdb.set_trace()
return context
class ListarUsuarioView(PermissionRequiredMixin, ListView):
model = get_user_model()
template_name = 'auth/user_list.html'

28
sapl/templates/base/RelatorioNormaMes_filter.html

@ -9,15 +9,22 @@
{% if show_results %}
<div class="actions btn-group pull-right" role="group">
<a href="{% url 'sapl.base:historico_tramitacoes' %}" class="btn btn-default">{% trans 'Fazer nova pesquisa' %}</a>
<a href="{% url 'sapl.base:normas_por_mes' %}" class="btn btn-default">{% trans 'Fazer nova pesquisa' %}</a>
</div>
<br /><br /><br /><br />
<b>PARÂMETROS DE PESQUISA:<br /></b>
&emsp;Ano: {{ ano }} <br />
<br /><br /><br />
<table class="table table-bordered table-hover">
{% for norma in object_list %}
<thead class="thead-default"><tr><td><h3>Mês: {{ norma.data }}</h3></td></tr></thead>
<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%">
<thead class="thead-default" >
<tr class="active">
<th>Matéria</th>
@ -25,14 +32,17 @@
</tr>
</thead>
<tbody>
{% for n in normas %}
<tr>
<td><a href="{% url 'sapl.norma:normajuridica_detail' norma.pk %}">
{{norma.tipo.descricao}} - {{norma.tipo.sigla}} {{norma.numero}}/{{norma.ano}}
<td><a href="{% url 'sapl.norma:normajuridica_detail' n.pk %}">
{{n.tipo.descricao}} - {{n.tipo.sigla}} {{n.numero}}/{{n.ano}}
</a></td>
<td>{{norma.ementa}}<br>{{norma.observacao}}</td>
<td>{{n.ementa}}<br>{{n.observacao}}</td>
</tr>
</tbody>
{% endfor %}
</tbody>
</table>
</div>
{% endfor %}
{% endif %}
{% endblock base_content %}

48
sapl/templates/base/RelatorioNormasVigencia_filter.html

@ -0,0 +1,48 @@
{% extends "crud/list.html" %}
{% load i18n %}
{% load crispy_forms_tags %}
{% block base_content %}
{% if not show_results %}
{% crispy filter.form %}
{% endif %}
{% if show_results %}
<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>
</div>
<br /><br /><br /><br />
<b>PARÂMETROS DE PESQUISA:<br /></b>
&emsp;Ano: {{ ano }} <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%">
<thead class="thead-default" >
<tr class="active">
<th>Matéria</th>
<th>Norma</th>
</tr>
</thead>
<tbody>
{% for n in normas %}
<tr>
<td><a href="{% url 'sapl.norma:normajuridica_detail' n.pk %}">
{{n.tipo.descricao}} - {{n.tipo.sigla}} {{n.numero}}/{{n.ano}}
</a></td>
<td>{{n.ementa}}<br>{{n.observacao}}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endfor %}
{% endif %}
{% endblock base_content %}

8
sapl/templates/base/relatorios_list.html

@ -49,8 +49,12 @@
<td> Audiência Pública com o tipo. </td>
</tr>
<tr>
<td><a href="{% url 'sapl.base:atos_por_mes' %}">Atos</a></td>
<td> Atos publicados por mês. </td>
<td><a href="{% url 'sapl.base:normas_por_mes' %}">Normas por mês</a></td>
<td> Normas publicadas por mês. </td>
</tr>
<tr>
<td><a href="{% url 'sapl.base:normas_por_vigencia' %}">Normas por vigência</a></td>
<td> Normas vigentes ou não vigentes. </td>
</tr>
</tbody>
</table>

Loading…
Cancel
Save