From 812a9e2ba06117e2ee373882f91eb4d71ffa0a91 Mon Sep 17 00:00:00 2001 From: Leandro Roberto Date: Fri, 4 Jan 2019 09:34:53 -0200 Subject: [PATCH] retira empty label duplicado de choices MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit a nova versão do django_filter addicionada ao sapl já gerencia os empty labels. Adicioná-los manualmente estava fazendo com os fossem duplicados. --- sapl/materia/forms.py | 6 +----- sapl/norma/forms.py | 8 ++------ sapl/protocoloadm/forms.py | 8 ++------ sapl/sessao/forms.py | 6 +++--- sapl/utils.py | 5 +++++ 5 files changed, 13 insertions(+), 20 deletions(-) diff --git a/sapl/materia/forms.py b/sapl/materia/forms.py index 3c2c8c36e..63941e2c4 100644 --- a/sapl/materia/forms.py +++ b/sapl/materia/forms.py @@ -51,10 +51,6 @@ from .models import (AcompanhamentoMateria, Anexada, Autoria, DespachoInicial, TipoMateriaLegislativa, Tramitacao, UnidadeTramitacao) -def ANO_CHOICES(): - return [('', '---------')] + RANGE_ANOS - - def em_tramitacao(): return [('', 'Tanto Faz'), (1, 'Sim'), @@ -764,7 +760,7 @@ class MateriaLegislativaFilterSet(django_filters.FilterSet): ano = django_filters.ChoiceFilter(required=False, label='Ano da Matéria', - choices=ANO_CHOICES) + choices=RANGE_ANOS) autoria__autor = django_filters.CharFilter(widget=forms.HiddenInput()) diff --git a/sapl/norma/forms.py b/sapl/norma/forms.py index 3429e1267..bdac45d89 100644 --- a/sapl/norma/forms.py +++ b/sapl/norma/forms.py @@ -21,10 +21,6 @@ from .models import (AnexoNormaJuridica, AssuntoNorma, NormaJuridica, NormaRelac TipoNormaJuridica, AutoriaNorma) -def ANO_CHOICES(): - return [('', '---------')] + RANGE_ANOS - - def get_esferas(): return [('E', 'Estadual'), ('F', 'Federal'), @@ -44,7 +40,7 @@ class NormaFilterSet(django_filters.FilterSet): ano = django_filters.ChoiceFilter(required=False, label='Ano', - choices=ANO_CHOICES) + choices=RANGE_ANOS) ementa = django_filters.CharFilter(lookup_expr='icontains') @@ -103,7 +99,7 @@ class NormaJuridicaForm(ModelForm): ano_materia = forms.ChoiceField( label='Ano Matéria', required=False, - choices=ANO_CHOICES, + choices=RANGE_ANOS, widget=forms.Select(attrs={'autocomplete': 'off'}) ) diff --git a/sapl/protocoloadm/forms.py b/sapl/protocoloadm/forms.py index bd017fc8e..76f3a4986 100644 --- a/sapl/protocoloadm/forms.py +++ b/sapl/protocoloadm/forms.py @@ -37,10 +37,6 @@ NATUREZA_PROCESSO = [('', '---------'), ('1', 'Legislativo')] -def ANO_CHOICES(): - return [('', '---------')] + RANGE_ANOS - - EM_TRAMITACAO = [('', '---------'), (0, 'Sim'), (1, 'Não')] @@ -73,7 +69,7 @@ class ProtocoloFilterSet(django_filters.FilterSet): ano = django_filters.ChoiceFilter(required=False, label='Ano', - choices=ANO_CHOICES) + choices=RANGE_ANOS) assunto_ementa = django_filters.CharFilter(lookup_expr='icontains') @@ -160,7 +156,7 @@ class DocumentoAdministrativoFilterSet(django_filters.FilterSet): ano = django_filters.ChoiceFilter(required=False, label='Ano', - choices=ANO_CHOICES) + choices=RANGE_ANOS) tramitacao = django_filters.ChoiceFilter(required=False, label='Em Tramitação?', diff --git a/sapl/sessao/forms.py b/sapl/sessao/forms.py index e508a0608..a09f04053 100644 --- a/sapl/sessao/forms.py +++ b/sapl/sessao/forms.py @@ -43,11 +43,11 @@ def recupera_anos(): def ANO_CHOICES(): - return [('', '---------')] + recupera_anos() + return recupera_anos() -MES_CHOICES = [('', '---------')] + RANGE_MESES -DIA_CHOICES = [('', '---------')] + RANGE_DIAS_MES +MES_CHOICES = RANGE_MESES +DIA_CHOICES = RANGE_DIAS_MES ORDENACAO_RESUMO = [('cont_mult', 'Conteúdo Multimídia'), diff --git a/sapl/utils.py b/sapl/utils.py index 77e1cec2d..7b00b3f9e 100644 --- a/sapl/utils.py +++ b/sapl/utils.py @@ -322,6 +322,11 @@ LISTA_DE_UFS = [ RANGE_ANOS = [(year, year) for year in range(timezone.now().year, 1889, -1)] + +def ANO_CHOICES(): + return [('', '---------')] + RANGE_ANOS + + RANGE_MESES = [ (1, 'Janeiro'), (2, 'Fevereiro'),