From fead77b36703b7fadf0c1f99dc452cf3d0eb9015 Mon Sep 17 00:00:00 2001 From: Eduardo Calil Date: Thu, 29 Jun 2017 19:21:28 -0300 Subject: [PATCH] =?UTF-8?q?Conserta=20bug=20quando=20parlamentar=20n=C3=A3?= =?UTF-8?q?o=20possui=20autor=20relacionado?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sapl/parlamentares/views.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/sapl/parlamentares/views.py b/sapl/parlamentares/views.py index 061ecb914..77ad62cf7 100644 --- a/sapl/parlamentares/views.py +++ b/sapl/parlamentares/views.py @@ -488,9 +488,18 @@ class ParlamentarMateriasView(FormView): @xframe_options_exempt def get(self, request, *args, **kwargs): parlamentar_pk = kwargs['pk'] - autor = Autor.objects.get( - content_type=ContentType.objects.get_for_model(Parlamentar), - object_id=parlamentar_pk) + + try: + autor = Autor.objects.get( + content_type=ContentType.objects.get_for_model(Parlamentar), + object_id=parlamentar_pk) + except ObjectDoesNotExist: + mensagem = _('Este Parlamentar não é autor de matéria.') + messages.add_message(request, messages.ERROR, mensagem) + return HttpResponseRedirect( + reverse( + 'sapl.parlamentares:parlamentar_detail', + kwargs={'pk': parlamentar_pk})) autoria = Autoria.objects.filter( autor=autor, primeiro_autor=True).values(