Browse Source

Fix #573

pull/585/head
Eduardo Edson Batista Cordeiro Alves 8 years ago
parent
commit
b866b02cf9
  1. 13
      sapl/parlamentares/models.py
  2. 4
      sapl/parlamentares/views.py

13
sapl/parlamentares/models.py

@ -18,11 +18,16 @@ class Legislatura(models.Model):
verbose_name = _('Legislatura')
verbose_name_plural = _('Legislaturas')
def atual(self):
current_year = datetime.now().year
if(self.data_inicio.year <= current_year and
self.data_fim.year >= current_year):
return True
else:
return False
def __str__(self):
# XXX Usar id mesmo? Ou criar campo para nº legislatura?
current_date = datetime.now().year
if(self.data_inicio.year <= current_date and
self.data_fim.year >= current_date):
if self.atual():
current = ' (%s)' % _('Atual')
else:
current = ''

4
sapl/parlamentares/views.py

@ -341,7 +341,9 @@ class ParlamentarCrud(Crud):
try:
legislatura_id = int(self.request.GET['periodo'])
except MultiValueDictKeyError:
legislatura_id = legislaturas.first().id
for l in Legislatura.objects.all():
if l.atual():
return l.id
return legislatura_id
else:
return 0

Loading…
Cancel
Save