From a43742d539533044bb0ed2de5fa664243160a040 Mon Sep 17 00:00:00 2001 From: Edward Ribeiro Date: Wed, 9 Mar 2016 14:31:00 -0300 Subject: [PATCH] =?UTF-8?q?Remove=20imports=20e=20fun=C3=A7=C3=B5es=20desn?= =?UTF-8?q?ecess=C3=A1rias=20e=20transforma=20m=C3=A9todos=20em=20vari?= =?UTF-8?q?=C3=A1veis?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- materia/forms.py | 7 ------- protocoloadm/forms.py | 34 +++++++++------------------------- 2 files changed, 9 insertions(+), 32 deletions(-) diff --git a/materia/forms.py b/materia/forms.py index d7cdeb5ca..ab1c63bd9 100644 --- a/materia/forms.py +++ b/materia/forms.py @@ -1,5 +1,3 @@ -from datetime import date - from crispy_forms.helper import FormHelper from crispy_forms.layout import Column, Fieldset, Layout, Submit from django import forms @@ -19,11 +17,6 @@ from .models import (AcompanhamentoMateria, Anexada, Autor, Autoria, TipoMateriaLegislativa, Tramitacao, UnidadeTramitacao) -def get_range_anos(): - return [('', 'Selecione')] \ - + [(year, year) for year in range(date.today().year, 1960, -1)] - - def get_regimes_tramitacao(): return [('1', 'Normal'), ('3', 'Urgência'), diff --git a/protocoloadm/forms.py b/protocoloadm/forms.py index 338e48e82..c886282f4 100644 --- a/protocoloadm/forms.py +++ b/protocoloadm/forms.py @@ -1,5 +1,3 @@ -from datetime import date - from crispy_forms.helper import FormHelper from crispy_forms.layout import HTML, Field, Fieldset, Layout, Submit from django import forms @@ -11,26 +9,19 @@ from django.utils.translation import ugettext_lazy as _ import crispy_layout_mixin from crispy_layout_mixin import form_actions from materia.models import TipoMateriaLegislativa +from sapl.utils import RANGE_ANOS from .models import (Autor, DocumentoAcessorioAdministrativo, DocumentoAdministrativo, Protocolo, TipoDocumentoAdministrativo, TramitacaoAdministrativo) +TRAMITACAO = [(True, 'Sim'), (False, 'Não')] -def get_range_anos(): - return [('', 'Selecione')] \ - + [(year, year) for year in range(date.today().year, 1960, -1)] - - -def tramitacao(): - return [('', '--------'), - (True, 'Sim'), - (False, 'Não')] +TIPOS_PROTOCOLO = [('0', 'Enviado'), ('1', 'Recebido')] - -TIPOS_PROTOCOLO = [('', 'Selecione'), - ('0', 'Enviado'), - ('1', 'Recebido')] +NATUREZA_PROCESSO = [('0', 'Administrativo'), + ('1', 'Legislativo'), + ('', 'Ambos')] class HorizontalRadioRenderer(forms.RadioSelect.renderer): @@ -41,8 +32,6 @@ class HorizontalRadioRenderer(forms.RadioSelect.renderer): class ProtocoloForm(forms.Form): - YEARS = get_range_anos() - tipo_protocolo = forms.ChoiceField(required=False, label=_('Tipo de Protocolo'), choices=TIPOS_PROTOCOLO, @@ -53,7 +42,7 @@ class ProtocoloForm(forms.Form): label=_('Número de Protocolo'), required=False) ano = forms.ChoiceField(required=False, label='Ano', - choices=YEARS, + choices=RANGE_ANOS, widget=forms.Select( attrs={'class': 'selector'})) @@ -68,10 +57,7 @@ class ProtocoloForm(forms.Form): natureza_processo = forms.ChoiceField(required=False, label=_('Natureza Processo'), - choices=[ - ('0', 'Administrativo'), - ('1', 'Legislativo'), - ('', 'Ambos')], + choices=NATUREZA_PROCESSO, # widget=forms.RadioSelect( # renderer=HorizontalRadioRenderer) @@ -135,8 +121,6 @@ class ProtocoloForm(forms.Form): class AnularProcoloAdmForm(ModelForm): - YEARS = get_range_anos() - numero = forms.CharField(required=True, label=Protocolo._meta. get_field('numero').verbose_name @@ -144,7 +128,7 @@ class AnularProcoloAdmForm(ModelForm): ano = forms.ChoiceField(required=True, label=Protocolo._meta. get_field('ano').verbose_name, - choices=YEARS, + choices=RANGE_ANOS, widget=forms.Select(attrs={'class': 'selector'})) justificativa_anulacao = forms.CharField(required=True, label=Protocolo._meta.