From 245c72505434fd21c1afff8eae3427078a3316bb Mon Sep 17 00:00:00 2001 From: Eduardo Edson Batista Cordeiro Alves Date: Tue, 10 May 2016 12:23:56 -0300 Subject: [PATCH] =?UTF-8?q?Valida=20se=20uma=20proposi=C3=A7=C3=A3o=20est?= =?UTF-8?q?=C3=A1=20sendo=20enviada=20ou=20criada?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- materia/forms.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/materia/forms.py b/materia/forms.py index 945ba33c4..cd924567f 100644 --- a/materia/forms.py +++ b/materia/forms.py @@ -7,6 +7,7 @@ from django.db import models from django.db.models import Max from django.forms import ModelForm from django.utils.translation import ugettext_lazy as _ +from datetime import datetime import crispy_layout_mixin import sapl @@ -52,6 +53,12 @@ class ProposicaoForm(ModelForm): raise ValidationError("Arquivo muito grande. ( > 5mb )") return texto_original + def clean_data_envio(self): + data_envio = self.cleaned_data.get('data_envio') + if (not data_envio) and bool(self.initial): + data_envio = datetime.now() + return data_envio + def clean(self): cleaned_data = self.cleaned_data