From c6e61e7029ccb91d51e2efb2786f028eeaca0536 Mon Sep 17 00:00:00 2001 From: VictorFabreF Date: Tue, 6 Mar 2018 11:09:23 -0300 Subject: [PATCH] Fix #1669 (#1734) --- sapl/base/forms.py | 41 ++++++++++++++++++- sapl/base/urls.py | 6 ++- sapl/base/views.py | 19 ++++++++- ...elatorioDataFimPrazoTramitacao_filter.html | 34 +++++++++++++++ sapl/templates/base/relatorios_list.html | 4 ++ 5 files changed, 101 insertions(+), 3 deletions(-) create mode 100644 sapl/templates/base/RelatorioDataFimPrazoTramitacao_filter.html diff --git a/sapl/base/forms.py b/sapl/base/forms.py index 1181650ee..cdc6d25c8 100644 --- a/sapl/base/forms.py +++ b/sapl/base/forms.py @@ -466,7 +466,46 @@ class RelatorioHistoricoTramitacaoFilterSet(django_filters.FilterSet): self.form.helper = FormHelper() self.form.helper.form_method = 'GET' self.form.helper.layout = Layout( - Fieldset(_('Histórico de Tramita'), + Fieldset(_('Histórico de Tramitação'), + row1, row2, + form_actions(label='Pesquisar')) + ) + +class RelatorioDataFimPrazoTramitacaoFilterSet(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} + }} + + @property + def qs(self): + parent = super(RelatorioDataFimPrazoTramitacaoFilterSet, self).qs + return parent.distinct().order_by('-ano', 'tipo', 'numero') + + class Meta: + model = MateriaLegislativa + fields = ['tipo', 'tramitacao__unidade_tramitacao_local', + 'tramitacao__status', 'tramitacao__data_fim_prazo'] + + def __init__(self, *args, **kwargs): + super(RelatorioDataFimPrazoTramitacaoFilterSet, self).__init__( + *args, **kwargs) + + self.filters['tipo'].label = 'Tipo de Matéria' + + row1 = to_row([('tramitacao__data_fim_prazo', 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(_('Tramitações por fim de prazo'), row1, row2, form_actions(label='Pesquisar')) ) diff --git a/sapl/base/urls.py b/sapl/base/urls.py index 143a89ba8..3b7d76e40 100644 --- a/sapl/base/urls.py +++ b/sapl/base/urls.py @@ -16,7 +16,8 @@ from .views import (AlterarSenha, AppConfigCrud, CasaLegislativaCrud, RelatorioMateriasPorAnoAutorTipoView, RelatorioMateriasPorAutorView, RelatorioMateriasTramitacaoView, - RelatorioPresencaSessaoView, SaplSearchView) + RelatorioPresencaSessaoView, SaplSearchView, + RelatorioDataFimPrazoTramitacaoView) app_name = AppConfig.name @@ -83,6 +84,9 @@ urlpatterns = [ url(r'^sistema/relatorios/historico-tramitacoes$', RelatorioHistoricoTramitacaoView.as_view(), name='historico_tramitacoes'), + url(r'^sistema/relatorios/data-fim-prazo-tramitacoes$', + RelatorioDataFimPrazoTramitacaoView.as_view(), + name='data_fim_prazo_tramitacoes'), url(r'^sistema/relatorios/presenca$', RelatorioPresencaSessaoView.as_view(), name='presenca_sessao'), diff --git a/sapl/base/views.py b/sapl/base/views.py index f31ed1c58..386364420 100644 --- a/sapl/base/views.py +++ b/sapl/base/views.py @@ -33,7 +33,8 @@ from .forms import (AlterarSenhaForm, CasaLegislativaForm, RelatorioMateriasPorAnoAutorTipoFilterSet, RelatorioMateriasPorAutorFilterSet, RelatorioMateriasTramitacaoilterSet, - RelatorioPresencaSessaoFilterSet) + RelatorioPresencaSessaoFilterSet, + RelatorioDataFimPrazoTramitacaoFilterSet) from .models import AppConfig, CasaLegislativa @@ -357,6 +358,22 @@ class RelatorioHistoricoTramitacaoView(FilterView): return context +class RelatorioDataFimPrazoTramitacaoView(FilterView): + model = MateriaLegislativa + filterset_class = RelatorioDataFimPrazoTramitacaoFilterSet + template_name = 'base/RelatorioDataFimPrazoTramitacao_filter.html' + + def get_context_data(self, **kwargs): + context = super(RelatorioDataFimPrazoTramitacaoView, + self).get_context_data(**kwargs) + context['title'] = _('Fim de Prazo de Tramitações') + qr = self.request.GET.copy() + context['filter_url'] = ('&' + qr.urlencode()) if len(qr) > 0 else '' + + context['show_results'] = show_results_filter_set(qr) + + return context + class RelatorioMateriasTramitacaoView(FilterView): model = MateriaLegislativa diff --git a/sapl/templates/base/RelatorioDataFimPrazoTramitacao_filter.html b/sapl/templates/base/RelatorioDataFimPrazoTramitacao_filter.html new file mode 100644 index 000000000..1fccf1268 --- /dev/null +++ b/sapl/templates/base/RelatorioDataFimPrazoTramitacao_filter.html @@ -0,0 +1,34 @@ +{% extends "crud/list.html" %} +{% load i18n %} +{% load crispy_forms_tags %} + +{% block base_content %} + {% if not show_results %} + {% crispy filter.form %} + {% endif %} + + {% if show_results %} +
+ {% 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 %} \ No newline at end of file diff --git a/sapl/templates/base/relatorios_list.html b/sapl/templates/base/relatorios_list.html index c7e47bd69..1bd0f5eda 100644 --- a/sapl/templates/base/relatorios_list.html +++ b/sapl/templates/base/relatorios_list.html @@ -36,6 +36,10 @@ Histórico de tramitações Histórico de tramitações por período e local informados. + + Tramitações por fim de prazo + Tramitações com fim de prazo no intervalo informado. +