From dd1ed58b5050ddbb83f9b642c5b7bb2d2bf9cae6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Cantu=C3=A1ria?= Date: Tue, 14 Jan 2020 14:26:21 -0300 Subject: [PATCH] =?UTF-8?q?Trata=20erro=20caso=20n=C3=A3o=20tenha=20legisl?= =?UTF-8?q?atura=20(#3074)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sapl/parlamentares/views.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sapl/parlamentares/views.py b/sapl/parlamentares/views.py index dfbd4a224..020335eef 100644 --- a/sapl/parlamentares/views.py +++ b/sapl/parlamentares/views.py @@ -645,8 +645,11 @@ class ParlamentarCrud(Crud): context['legislatura_id'] = self.take_legislatura_id() # Pega a Legislatura - legislatura = Legislatura.objects.get( - id=context['legislatura_id']) + try: + legislatura = Legislatura.objects.get(id=context['legislatura_id']) + except ObjectDoesNotExist: + self.logger.error("user={}. Não há nenhuma legislação cadastrada.".format(username)) + return context for row in context['rows']: