From 7c87db4f884fbf231124597db4733d7ceae03c2e Mon Sep 17 00:00:00 2001 From: Eduardo Edson Batista Cordeiro Alves Date: Fri, 2 Sep 2016 14:38:43 -0300 Subject: [PATCH] =?UTF-8?q?Adiciona=20relat=C3=B3rio=20de=20hist=C3=B3rico?= =?UTF-8?q?=20de=20tramita=C3=A7=C3=B5es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sapl/base/forms.py | 35 +++++++++++++++++++ sapl/base/urls.py | 5 +++ sapl/base/views.py | 16 ++++++++- .../RelatorioHistoricoTramitacao_filter.html | 34 ++++++++++++++++++ sapl/templates/base/relatorios_list.html | 2 +- 5 files changed, 90 insertions(+), 2 deletions(-) create mode 100644 sapl/templates/base/RelatorioHistoricoTramitacao_filter.html diff --git a/sapl/base/forms.py b/sapl/base/forms.py index 4aa02c21b..5af6ee179 100644 --- a/sapl/base/forms.py +++ b/sapl/base/forms.py @@ -37,6 +37,41 @@ class RangeWidgetOverride(forms.MultiWidget): return ''.join(rendered_widgets) +class RelatorioHistoricoTramitacaoFilterSet(django_filters.FilterSet): + + filter_overrides = {models.DateField: { + 'filter_class': django_filters.DateFromToRangeFilter, + 'extra': lambda f: { + 'label': '%s (%s)' % (f.verbose_name, _('Inicial - Final')), + 'widget': RangeWidgetOverride} + }} + + class Meta: + model = MateriaLegislativa + fields = ['tipo', 'tramitacao__unidade_tramitacao_local', + 'tramitacao__status', 'tramitacao__data_tramitacao'] + + def __init__(self, *args, **kwargs): + super(RelatorioHistoricoTramitacaoFilterSet, self).__init__( + *args, **kwargs) + + self.filters['tipo'].label = 'Tipo de Matéria' + + row1 = to_row([('tramitacao__data_tramitacao', 12)]) + row2 = to_row( + [('tipo', 4), + ('tramitacao__unidade_tramitacao_local', 4), + ('tramitacao__status', 4)]) + + self.form.helper = FormHelper() + self.form.helper.form_method = 'GET' + self.form.helper.layout = Layout( + Fieldset(_('Histórico de Tramita'), + row1, row2, + form_actions(save_label='Pesquisar')) + ) + + class RelatorioMateriasTramitacaoilterSet(django_filters.FilterSet): ano = django_filters.ChoiceFilter(required=True, diff --git a/sapl/base/urls.py b/sapl/base/urls.py index a59a1f924..b3dcac6ea 100644 --- a/sapl/base/urls.py +++ b/sapl/base/urls.py @@ -5,6 +5,7 @@ from django.views.generic.base import TemplateView from .apps import AppConfig from .forms import LoginForm from .views import (CasaLegislativaCrud, HelpView, + RelatorioHistoricoTramitacaoView, RelatorioMateriasPorAnoAutorTipoView, RelatorioMateriasPorAutorView, RelatorioMateriasTramitacaoView) @@ -35,4 +36,8 @@ urlpatterns = [ url(r'^relatorio/materia-por-tramitacao$', RelatorioMateriasTramitacaoView.as_view(), name='materia_por_tramitacao'), + url(r'^relatorio/historico-tramitacoes$', + RelatorioHistoricoTramitacaoView.as_view(), + name='historico_tramitacoes'), + ] diff --git a/sapl/base/views.py b/sapl/base/views.py index db3ab016f..ca5d735a3 100644 --- a/sapl/base/views.py +++ b/sapl/base/views.py @@ -10,7 +10,7 @@ from sapl.crud.base import (Crud, CrudBaseMixin, CrudCreateView, from sapl.materia.models import MateriaLegislativa, TipoMateriaLegislativa from sapl.utils import permissao_tb_aux -from .forms import (CasaLegislativaForm, +from .forms import (CasaLegislativaForm, RelatorioHistoricoTramitacaoFilterSet, RelatorioMateriasPorAnoAutorTipoFilterSet, RelatorioMateriasPorAutorFilterSet, RelatorioMateriasTramitacaoilterSet) @@ -21,6 +21,20 @@ def get_casalegislativa(): return CasaLegislativa.objects.first() +class RelatorioHistoricoTramitacaoView(FilterView): + model = MateriaLegislativa + filterset_class = RelatorioHistoricoTramitacaoFilterSet + template_name = 'base/RelatorioHistoricoTramitacao_filter.html' + + def get_context_data(self, **kwargs): + context = super(RelatorioHistoricoTramitacaoView, + self).get_context_data(**kwargs) + context['title'] = _('Histórico de Tramitações') + qr = self.request.GET.copy() + context['filter_url'] = ('&' + qr.urlencode()) if len(qr) > 0 else '' + return context + + class RelatorioMateriasTramitacaoView(FilterView): model = MateriaLegislativa filterset_class = RelatorioMateriasTramitacaoilterSet diff --git a/sapl/templates/base/RelatorioHistoricoTramitacao_filter.html b/sapl/templates/base/RelatorioHistoricoTramitacao_filter.html new file mode 100644 index 000000000..8cba5d186 --- /dev/null +++ b/sapl/templates/base/RelatorioHistoricoTramitacao_filter.html @@ -0,0 +1,34 @@ +{% extends "crud/list.html" %} +{% load i18n %} +{% load crispy_forms_tags %} + +{% block base_content %} + {% if not filter_url %} + {% crispy filter.form %} + {% endif %} + + {% if filter_url %} +
+ {% trans 'Fazer nova pesquisa' %} +
+



+ + + + + + + + + {% for materia in object_list %} + + + + + {% endfor %} + +
MatériaEmenta
+ {{materia.tipo.descricao}} - {{materia.tipo.sigla}} {{materia.numero}}/{{materia.ano}} + {{materia.ementa}}
+ {% endif %} +{% endblock base_content %} diff --git a/sapl/templates/base/relatorios_list.html b/sapl/templates/base/relatorios_list.html index 44cefb933..49edf946c 100644 --- a/sapl/templates/base/relatorios_list.html +++ b/sapl/templates/base/relatorios_list.html @@ -33,7 +33,7 @@ Atas de Sessão Plenária. - Histórico de tramitações + Histórico de tramitações Histórico de tramitações por período e local informados.