From 88945249a6a8532a87de75da41d525ebe89dc724 Mon Sep 17 00:00:00 2001 From: Eduardo Calil Date: Mon, 7 Mar 2016 18:05:17 -0300 Subject: [PATCH] Coloca as 'choices' do formulario no models em Comissoes --- comissoes/forms.py | 21 +++++++++------------ comissoes/models.py | 9 ++++++--- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/comissoes/forms.py b/comissoes/forms.py index 55ca1d2d9..450a840e6 100644 --- a/comissoes/forms.py +++ b/comissoes/forms.py @@ -124,18 +124,6 @@ class ParticipacaoCadastroForm(ModelForm): empty_label='Selecione', ) - data_designacao = forms.DateField(label=u'Data Designação', - input_formats=['%d/%m/%Y'], - required=True, - widget=forms.DateInput( - format='%d/%m/%Y')) - - data_desligamento = forms.DateField(label=u'Data Desligamento', - input_formats=['%d/%m/%Y'], - required=False, - widget=forms.DateInput( - format='%d/%m/%Y')) - class Meta: model = Participacao fields = ['parlamentar_id', @@ -146,6 +134,15 @@ class ParticipacaoCadastroForm(ModelForm): 'motivo_desligamento', 'observacao'] + widgets = { + 'data_designacao': forms.DateInput(format='%d/%m/%Y'), + 'data_desligamento': forms.DateInput(format='%d/%m/%Y'), + } + input_formats = { + 'data_designacao': ['%d/%m/%Y'], + 'data_desligamento': ['%d/%m/%Y'], + } + def __init__(self, *args, **kwargs): self.helper = FormHelper() diff --git a/comissoes/models.py b/comissoes/models.py index 6e41e0e01..a80bfb8f1 100644 --- a/comissoes/models.py +++ b/comissoes/models.py @@ -125,9 +125,12 @@ class Participacao(models.Model): # ComposicaoComissao parlamentar = models.ForeignKey(Parlamentar) cargo = models.ForeignKey(CargoComissao) titular = models.BooleanField(verbose_name=_('Titular')) - data_designacao = models.DateField(verbose_name=_('Data Designação')) - data_desligamento = models.DateField( - blank=True, null=True, verbose_name=_('Data Desligamento')) + data_designacao = models.DateField(blank=True, + null=True, + verbose_name=_('Data Designação')) + data_desligamento = models.DateField(blank=True, + null=True, + verbose_name=_('Data Desligamento')) motivo_desligamento = models.CharField( max_length=150, blank=True,