From 69e24b48a6e14173bb291bb947f79c6aa7bccc38 Mon Sep 17 00:00:00 2001 From: Eduardo Edson Batista Cordeiro Alves Date: Tue, 21 Feb 2017 15:57:07 -0300 Subject: [PATCH] Fix #904 --- sapl/parlamentares/views.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/sapl/parlamentares/views.py b/sapl/parlamentares/views.py index e1a0e22df..1ee5299b8 100644 --- a/sapl/parlamentares/views.py +++ b/sapl/parlamentares/views.py @@ -1,5 +1,5 @@ - from django.contrib import messages +from django.core.exceptions import ObjectDoesNotExist from django.core.urlresolvers import reverse, reverse_lazy from django.http.response import HttpResponseRedirect from django.utils.datastructures import MultiValueDictKeyError @@ -301,9 +301,15 @@ class ParlamentarCrud(Crud): legislatura_id = self.take_legislatura_id() if legislatura_id != 0: - queryset = queryset.filter( + return queryset.filter( mandato__legislatura_id=legislatura_id) - return queryset + else: + try: + l = Legislatura.objects.all().order_by('-data_inicio').first().pk + except ObjectDoesNotExist: + return [] + else: + return queryset.filter(mandato__legislatura_id=l) def get_headers(self): return ['', _('Parlamentar'), _('Partido'), _('Ativo?')]