From 724440bef79fb139a16f4bc86be3c1ae7dd0d926 Mon Sep 17 00:00:00 2001 From: Edward <9326037+edwardoliveira@users.noreply.github.com> Date: Sat, 23 Apr 2022 10:29:34 -0300 Subject: [PATCH] =?UTF-8?q?Filtra=20relat=C3=B3rio=20de=20normas=20em=20vi?= =?UTF-8?q?g=C3=AAncia=20por=20tipo=20de=20norma=20(#3540)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fixes #3535 * Add filter tipo em Normas por mes ano Co-authored-by: Gustavo --- sapl/base/forms.py | 16 +++++++++++++--- sapl/utils.py | 6 ++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/sapl/base/forms.py b/sapl/base/forms.py index b6d6c6c6d..e8242dc43 100644 --- a/sapl/base/forms.py +++ b/sapl/base/forms.py @@ -39,7 +39,7 @@ from sapl.utils import (autor_label, autor_modal, ChoiceWithoutValidationField, choice_anos_com_normas, choice_anos_com_materias, FilterOverridesMetaMixin, FileFieldCheckMixin, ImageThumbnailFileInput, qs_override_django_filter, - RANGE_ANOS, YES_NO_CHOICES, + RANGE_ANOS, YES_NO_CHOICES, choice_tipos_normas, GoogleRecapthaMixin, parlamentares_ativos) from .models import AppConfig, CasaLegislativa @@ -880,6 +880,11 @@ class RelatorioNormasMesFilterSet(django_filters.FilterSet): label='Ano da Norma', choices=choice_anos_com_normas, initial=ultimo_ano_com_norma) + + tipo = django_filters.ChoiceFilter(required=False, + label='Tipo Norma', + choices=choice_tipos_normas, + initial=0) class Meta: model = NormaJuridica @@ -892,7 +897,7 @@ class RelatorioNormasMesFilterSet(django_filters.FilterSet): self.filters['ano'].label = 'Ano' self.form.fields['ano'].required = True - row1 = to_row([('ano', 12)]) + row1 = to_row([('ano', 6), ('tipo', 6)]) buttons = FormActions( *[ @@ -971,6 +976,11 @@ class RelatorioNormasVigenciaFilterSet(django_filters.FilterSet): choices=choice_anos_com_normas, initial=ultimo_ano_com_norma) + tipo = django_filters.ChoiceFilter(required=False, + label='Tipo Norma', + choices=choice_tipos_normas, + initial=0) + vigencia = forms.ChoiceField( label=_('Vigência'), choices=[(True, "Vigente"), (False, "Não vigente")], @@ -986,7 +996,7 @@ class RelatorioNormasVigenciaFilterSet(django_filters.FilterSet): self.form.fields['ano'].required = True self.form.fields['vigencia'] = self.vigencia - row1 = to_row([('ano', 12)]) + row1 = to_row([('ano', 6), ('tipo', 6)]) row2 = to_row([('vigencia', 12)]) buttons = FormActions( diff --git a/sapl/utils.py b/sapl/utils.py index 53b76810a..c00dc0716 100644 --- a/sapl/utils.py +++ b/sapl/utils.py @@ -494,6 +494,12 @@ def choice_anos_com_normas(): return choice_anos(NormaJuridica) +def choice_tipos_normas(): + from sapl.norma.models import TipoNormaJuridica + return [(id, descricao) for (id, descricao) in + TipoNormaJuridica.objects.all().values_list('id', 'descricao')] + + def choice_anos_com_protocolo(): from sapl.protocoloadm.models import Protocolo return choice_anos(Protocolo)