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 = _('Legislatura')
verbose_name_plural = _('Legislaturas') 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): def __str__(self):
# XXX Usar id mesmo? Ou criar campo para nº legislatura? if self.atual():
current_date = datetime.now().year
if(self.data_inicio.year <= current_date and
self.data_fim.year >= current_date):
current = ' (%s)' % _('Atual') current = ' (%s)' % _('Atual')
else: else:
current = '' current = ''

4
sapl/parlamentares/views.py

@ -341,7 +341,9 @@ class ParlamentarCrud(Crud):
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 for l in Legislatura.objects.all():
if l.atual():
return l.id
return legislatura_id return legislatura_id
else: else:
return 0 return 0

Loading…
Cancel
Save