diff --git a/base/models.py b/base/models.py index e2f1cddf6..ad7108bac 100644 --- a/base/models.py +++ b/base/models.py @@ -1,5 +1,6 @@ from django.db import models from django.utils.translation import ugettext_lazy as _ + from sapl.utils import UF diff --git a/materia/forms.py b/materia/forms.py index 9c6112d55..d7cdeb5ca 100644 --- a/materia/forms.py +++ b/materia/forms.py @@ -1,7 +1,7 @@ from datetime import date from crispy_forms.helper import FormHelper -from crispy_forms.layout import Column, Fieldset, Layout +from crispy_forms.layout import Column, Fieldset, Layout, Submit from django import forms from django.forms import ModelForm from django.utils.safestring import mark_safe @@ -54,7 +54,6 @@ class HorizontalRadioRenderer(forms.RadioSelect.renderer): class ProposicaoForm(ModelForm): - tipo_materia = forms.ModelChoiceField( label=_('Matéria Vinculada'), required=False, diff --git a/materia/models.py b/materia/models.py index bf3fabd0e..a358b303b 100644 --- a/materia/models.py +++ b/materia/models.py @@ -1,12 +1,10 @@ -from datetime import date - from django.db import models from django.utils.translation import ugettext_lazy as _ from model_utils import Choices from comissoes.models import Comissao from parlamentares.models import Parlamentar, Partido -from sapl.utils import YES_NO_CHOICES, xstr +from sapl.utils import RANGE_ANOS, YES_NO_CHOICES, xstr class TipoMateriaLegislativa(models.Model): @@ -64,7 +62,8 @@ class MateriaLegislativa(models.Model): tipo = models.ForeignKey(TipoMateriaLegislativa, verbose_name=_('Tipo')) numero = models.PositiveIntegerField(verbose_name=_('Número')) - ano = models.PositiveSmallIntegerField(verbose_name=_('Ano')) + ano = models.PositiveSmallIntegerField(verbose_name=_('Ano'), + choices=RANGE_ANOS) numero_protocolo = models.PositiveIntegerField( blank=True, null=True, verbose_name=_('Núm. Protocolo')) data_apresentacao = models.DateField(verbose_name=_('Data Apresentação')) @@ -85,7 +84,7 @@ class MateriaLegislativa(models.Model): numero_origem_externa = models.CharField( max_length=5, blank=True, verbose_name=_('Número')) ano_origem_externa = models.PositiveSmallIntegerField( - blank=True, null=True, verbose_name=_('Ano')) + blank=True, null=True, verbose_name=_('Ano'), choices=RANGE_ANOS) data_origem_externa = models.DateField( blank=True, null=True, verbose_name=_('Data')) local_origem_externa = models.ForeignKey( @@ -302,9 +301,6 @@ class MateriaAssunto(models.Model): 'materia': self.materia, 'assunto': self.assunto} -RANGE_ANOS = [(year, year) for year in range(date.today().year, 1889, -1)] - - class Numeracao(models.Model): materia = models.ForeignKey(MateriaLegislativa) tipo_materia = models.ForeignKey( diff --git a/norma/models.py b/norma/models.py index b03264d64..37d48d20b 100644 --- a/norma/models.py +++ b/norma/models.py @@ -4,7 +4,7 @@ from django.utils.translation import ugettext_lazy as _ from model_utils import Choices from materia.models import MateriaLegislativa -from sapl.utils import YES_NO_CHOICES +from sapl.utils import RANGE_ANOS, YES_NO_CHOICES class AssuntoNorma(models.Model): @@ -76,7 +76,8 @@ class NormaJuridica(models.Model): TipoNormaJuridica, verbose_name=_('Tipo da Norma Juridica')) materia = models.ForeignKey(MateriaLegislativa, blank=True, null=True) numero = models.PositiveIntegerField(verbose_name=_('Número')) - ano = models.PositiveSmallIntegerField(verbose_name=_('Ano')) + ano = models.PositiveSmallIntegerField(verbose_name=_('Ano'), + choices=RANGE_ANOS) esfera_federacao = models.CharField( max_length=1, verbose_name=_('Esfera Federação'), diff --git a/parlamentares/models.py b/parlamentares/models.py index ac31e0133..a1055602d 100644 --- a/parlamentares/models.py +++ b/parlamentares/models.py @@ -4,7 +4,7 @@ from django.db import models from django.utils.translation import ugettext_lazy as _ from model_utils import Choices -from sapl.utils import YES_NO_CHOICES, UF +from sapl.utils import UF, YES_NO_CHOICES class Legislatura(models.Model): diff --git a/protocoloadm/models.py b/protocoloadm/models.py index fc9d1715f..1647749d4 100644 --- a/protocoloadm/models.py +++ b/protocoloadm/models.py @@ -5,7 +5,7 @@ from django.utils.translation import ugettext_lazy as _ from model_utils import Choices from materia.models import Autor, TipoMateriaLegislativa, UnidadeTramitacao -from sapl.utils import YES_NO_CHOICES +from sapl.utils import RANGE_ANOS, YES_NO_CHOICES class TipoDocumentoAdministrativo(models.Model): @@ -28,7 +28,8 @@ class DocumentoAdministrativo(models.Model): tipo = models.ForeignKey( TipoDocumentoAdministrativo, verbose_name=_('Tipo Documento')) numero = models.PositiveIntegerField(verbose_name=_('Número')) - ano = models.PositiveSmallIntegerField(verbose_name=_('Ano')) + ano = models.PositiveSmallIntegerField(verbose_name=_('Ano'), + choices=RANGE_ANOS) data = models.DateField(verbose_name=_('Data')) numero_protocolo = models.PositiveIntegerField( blank=True, null=True, verbose_name=_('Núm. Protocolo')) @@ -89,8 +90,10 @@ class DocumentoAcessorioAdministrativo(models.Model): class Protocolo(models.Model): numero = models.PositiveIntegerField( blank=False, null=False, verbose_name=_('Número de Protocolo')) - ano = models.PositiveSmallIntegerField( - blank=False, null=False, verbose_name=_('Ano do Protocolo')) + ano = models.PositiveSmallIntegerField(blank=False, + null=False, + choices=RANGE_ANOS, + verbose_name=_('Ano do Protocolo')) data = models.DateField() hora = models.TimeField() timestamp = models.DateTimeField() diff --git a/relatorios/views.py b/relatorios/views.py index fef8bb19f..fa0e3b932 100644 --- a/relatorios/views.py +++ b/relatorios/views.py @@ -12,9 +12,7 @@ from parlamentares.models import (CargoMesa, ComposicaoMesa, Filiacao, Parlamentar) from protocoloadm.models import (DocumentoAdministrativo, Protocolo, TramitacaoAdministrativo) - from sapl.utils import UF - from sessao.models import (ExpedienteMateria, ExpedienteSessao, Orador, OradorExpediente, OrdemDia, PresencaOrdemDia, RegistroVotacao, SessaoPlenaria, diff --git a/sapl/utils.py b/sapl/utils.py index 189372479..615a6b1e9 100644 --- a/sapl/utils.py +++ b/sapl/utils.py @@ -1,3 +1,4 @@ +from datetime import date from functools import wraps from django.apps import apps @@ -95,3 +96,5 @@ UF = ( ('TO', 'Tocantins'), ('EX', 'Exterior'), ) + +RANGE_ANOS = [(year, year) for year in range(date.today().year, 1889, -1)]