From ab2147ff8fd280745f96bd681053111078288c67 Mon Sep 17 00:00:00 2001 From: Edward Ribeiro Date: Thu, 6 Oct 2016 16:00:57 -0300 Subject: [PATCH] =?UTF-8?q?Adia=20recupera=C3=A7=C3=A3o=20de=20range=20de?= =?UTF-8?q?=20anos=20at=C3=A9=20carregamento=20de=20p=C3=A1gina=20(evitar?= =?UTF-8?q?=20cache)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sapl/materia/forms.py | 3 ++- sapl/protocoloadm/forms.py | 3 ++- sapl/sessao/forms.py | 7 +++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/sapl/materia/forms.py b/sapl/materia/forms.py index f4f054c6e..f2e2f113a 100644 --- a/sapl/materia/forms.py +++ b/sapl/materia/forms.py @@ -27,7 +27,8 @@ from .models import (AcompanhamentoMateria, Anexada, Autor, Autoria, Numeracao, Proposicao, Relatoria, TipoMateriaLegislativa, Tramitacao, UnidadeTramitacao) -ANO_CHOICES = [('', '---------')] + RANGE_ANOS +def ANO_CHOICES(): + return [('', '---------')] + RANGE_ANOS def em_tramitacao(): diff --git a/sapl/protocoloadm/forms.py b/sapl/protocoloadm/forms.py index c1bf9f99e..60f42d4aa 100644 --- a/sapl/protocoloadm/forms.py +++ b/sapl/protocoloadm/forms.py @@ -26,7 +26,8 @@ NATUREZA_PROCESSO = [('', 'Ambos'), ('1', 'Legislativo')] -ANO_CHOICES = [('', '---------')] + RANGE_ANOS +def ANO_CHOICES(): + return [('', '---------')] + RANGE_ANOS EM_TRAMITACAO = [('', 'Tanto Faz'), (0, 'Sim'), diff --git a/sapl/sessao/forms.py b/sapl/sessao/forms.py index 0ac7b1f0e..b38997972 100644 --- a/sapl/sessao/forms.py +++ b/sapl/sessao/forms.py @@ -19,7 +19,7 @@ from .models import (Bancada, ExpedienteMateria, Orador, OradorExpediente, SessaoPlenariaPresenca) -def pega_anos(): +def recupera_anos(): try: anos_list = SessaoPlenaria.objects.all().dates('data_inicio', 'year') anos = [(k.year, k.year) for k in anos_list] @@ -28,7 +28,9 @@ def pega_anos(): return [] -ANO_CHOICES = [('', '---------')] + pega_anos() +def ANO_CHOICES(): + return [('', '---------')] + recupera_anos() + MES_CHOICES = [('', '---------')] + RANGE_MESES DIA_CHOICES = [('', '---------')] + RANGE_DIAS_MES @@ -166,6 +168,7 @@ class VotacaoEditForm(forms.Form): class SessaoPlenariaFilterSet(django_filters.FilterSet): + data_inicio__year = django_filters.ChoiceFilter(required=False, label=u'Ano', choices=ANO_CHOICES)