Browse Source

Valida a tela de parlamentar caso a base esteja vazia

pull/521/head
Eduardo Edson Batista Cordeiro Alves 9 years ago
parent
commit
8cb80f1218
  1. 7
      sapl/parlamentares/views.py

7
sapl/parlamentares/views.py

@ -1,4 +1,5 @@
from django.contrib import messages from django.contrib import messages
from django.core.exceptions import ObjectDoesNotExist
from django.core.urlresolvers import reverse_lazy from django.core.urlresolvers import reverse_lazy
from django.shortcuts import redirect from django.shortcuts import redirect
from django.utils.datastructures import MultiValueDictKeyError from django.utils.datastructures import MultiValueDictKeyError
@ -114,17 +115,21 @@ class ParlamentarCrud(Crud):
legislaturas = Legislatura.objects.all().order_by( legislaturas = Legislatura.objects.all().order_by(
'-data_inicio', '-data_fim') '-data_inicio', '-data_fim')
if legislaturas:
try: try:
legislatura_id = int(self.request.GET['periodo']) legislatura_id = int(self.request.GET['periodo'])
except MultiValueDictKeyError: except MultiValueDictKeyError:
legislatura_id = legislaturas.first().id legislatura_id = legislaturas.first().id
return legislatura_id return legislatura_id
else:
return 0
def get_queryset(self): def get_queryset(self):
if self.take_legislatura_id() != 0:
mandatos = Mandato.objects.filter( mandatos = Mandato.objects.filter(
legislatura_id=self.take_legislatura_id()) legislatura_id=self.take_legislatura_id())
return mandatos return mandatos
return []
def get_rows(self, object_list): def get_rows(self, object_list):
parlamentares = [] parlamentares = []

Loading…
Cancel
Save