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