From 3f7a1808d49ff97a7092cc3b685ce1cb9d40d7f2 Mon Sep 17 00:00:00 2001 From: VictorFabreF Date: Tue, 21 Aug 2018 13:28:24 -0300 Subject: [PATCH] Melhora if's --- sapl/comissoes/forms.py | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/sapl/comissoes/forms.py b/sapl/comissoes/forms.py index b82a28477..49b7fc5be 100644 --- a/sapl/comissoes/forms.py +++ b/sapl/comissoes/forms.py @@ -245,34 +245,34 @@ class ComissaoForm(forms.ModelForm): if len(self.cleaned_data['nome']) > 100: msg = _('Nome da Comissão deve ter no máximo 50 caracteres.') raise ValidationError(msg) - if self.cleaned_data['data_extincao']: - if (self.cleaned_data['data_extincao'] < - self.cleaned_data['data_criacao']): + if (self.cleaned_data['data_extincao'] and + self.cleaned_data['data_extincao'] < + self.cleaned_data['data_criacao']): msg = _('Data de extinção não pode ser menor que a de criação') raise ValidationError(msg) - if self.cleaned_data['data_final_prevista_temp']: - if (self.cleaned_data['data_final_prevista_temp'] < - self.cleaned_data['data_criacao']): + if (self.cleaned_data['data_final_prevista_temp'] and + self.cleaned_data['data_final_prevista_temp'] < + self.cleaned_data['data_criacao']): msg = _('Data Prevista para Término não pode ser menor que a de criação') raise ValidationError(msg) - if self.cleaned_data['data_prorrogada_temp']: - if (self.cleaned_data['data_prorrogada_temp'] < - self.cleaned_data['data_criacao']): + if (self.cleaned_data['data_prorrogada_temp'] and + self.cleaned_data['data_prorrogada_temp'] < + self.cleaned_data['data_criacao']): msg = _('Data Novo Prazo não pode ser menor que a de criação') raise ValidationError(msg) - if self.cleaned_data['data_instalacao_temp']: - if (self.cleaned_data['data_instalacao_temp'] < - self.cleaned_data['data_criacao']): + if (self.cleaned_data['data_instalacao_temp'] and + self.cleaned_data['data_instalacao_temp'] < + self.cleaned_data['data_criacao']): msg = _('Data de Instalação não pode ser menor que a de criação') raise ValidationError(msg) - if self.cleaned_data['data_final_prevista_temp'] and self.cleaned_data['data_instalacao_temp']: - if (self.cleaned_data['data_final_prevista_temp'] < - self.cleaned_data['data_instalacao_temp']): + if (self.cleaned_data['data_final_prevista_temp'] and self.cleaned_data['data_instalacao_temp'] and + self.cleaned_data['data_final_prevista_temp'] < + self.cleaned_data['data_instalacao_temp']): msg = _('Data Prevista para Término não pode ser menor que a de Instalação') raise ValidationError(msg) - if self.cleaned_data['data_prorrogada_temp'] and self.cleaned_data['data_instalacao_temp']: - if (self.cleaned_data['data_prorrogada_temp'] < - self.cleaned_data['data_instalacao_temp']): + if (self.cleaned_data['data_prorrogada_temp'] and self.cleaned_data['data_instalacao_temp'] and + self.cleaned_data['data_prorrogada_temp'] < + self.cleaned_data['data_instalacao_temp']): msg = _('Data Novo Prazo não pode ser menor que a de Instalação') raise ValidationError(msg) return self.cleaned_data