From b87c9381ce0ca9d6722cacd268c537b4eb13b95f Mon Sep 17 00:00:00 2001 From: Edward Date: Wed, 28 Mar 2018 11:11:58 -0300 Subject: [PATCH] Fix #1809 (#1811) --- sapl/sessao/views.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/sapl/sessao/views.py b/sapl/sessao/views.py index c8070ee94..99ca51758 100644 --- a/sapl/sessao/views.py +++ b/sapl/sessao/views.py @@ -1444,22 +1444,24 @@ class ExpedienteView(FormMixin, DetailView): list_conteudo = request.POST.getlist('conteudo') for tipo, conteudo in zip(list_tipo, list_conteudo): - try: - ExpedienteSessao.objects.get( - sessao_plenaria_id=self.object.id, - tipo_id=tipo - ).delete() - except: - pass + + ExpedienteSessao.objects.filter( + sessao_plenaria_id=self.object.id, + tipo_id=tipo).delete() expediente = ExpedienteSessao() expediente.sessao_plenaria_id = self.object.id expediente.tipo_id = tipo expediente.conteudo = conteudo expediente.save() + + msg = _('Registro salvo com sucesso') + messages.add_message(self.request, messages.SUCCESS, msg) return self.form_valid(form) else: - return self.form_valid(form) + msg = _('Erro ao salvar registro') + messages.add_message(self.request, messages.SUCCESS, msg) + return self.form_invalid(form) def get(self, request, *args, **kwargs): self.object = self.get_object()