From b1e7f03e8ebdd8c09adbaba8d74bacbc38f76dac Mon Sep 17 00:00:00 2001 From: Eduardo Edson Batista Cordeiro Alves Date: Thu, 25 Aug 2016 10:52:57 -0300 Subject: [PATCH] =?UTF-8?q?Conserta=20adi=C3=A7=C3=A3o/evio=20de=20propopi?= =?UTF-8?q?=C3=A7=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sapl/materia/forms.py | 4 ++-- sapl/materia/views.py | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/sapl/materia/forms.py b/sapl/materia/forms.py index 054854e54..8f18e23a5 100644 --- a/sapl/materia/forms.py +++ b/sapl/materia/forms.py @@ -100,8 +100,8 @@ class ProposicaoForm(ModelForm): 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 = self.cleaned_data.get('data_envio') or None + if (not data_envio) and len(self.initial) > 1: data_envio = datetime.now() return data_envio diff --git a/sapl/materia/views.py b/sapl/materia/views.py index f31d53a65..3deff9217 100644 --- a/sapl/materia/views.py +++ b/sapl/materia/views.py @@ -397,12 +397,18 @@ class ProposicaoCrud(Crud): def get_initial(self): try: - autor_id = Autor.objects.get(id=self.request.user.id).id + autor_id = Autor.objects.get(user=self.request.user).id except MultipleObjectsReturned: msg = _('Este usuário está relacionado a mais de um autor. ' + 'Operação cancelada') messages.add_message(self.request, messages.ERROR, msg) return redirect(self.get_success_url()) + except ObjectDoesNotExist: + autor_id = Autor.objects.create( + user=self.request.user, + nome=str(self.request.user), + tipo_id=4).id + return {'autor': autor_id} else: return {'autor': autor_id}