From 5d839e0c6aeede519a35338d88e9cf2e17122a9c Mon Sep 17 00:00:00 2001 From: Edward Ribeiro Date: Mon, 16 Nov 2015 10:20:00 -0200 Subject: [PATCH] List legislaturas from latest to first. --- parlamentares/views.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/parlamentares/views.py b/parlamentares/views.py index 468c10bf5..73ae6d667 100644 --- a/parlamentares/views.py +++ b/parlamentares/views.py @@ -147,9 +147,10 @@ class ParlamentaresView(GenericView): def get(self, request, *args, **kwargs): form = ParlamentaresForm() + legislaturas = Legislatura.objects.all().order_by('-data_inicio','-data_fim') return self.render_to_response( - {'legislaturas': Legislatura.objects.all().order_by('-data_inicio'), - 'legislatura_id': Legislatura.objects.first().id, + {'legislaturas': legislaturas, + 'legislatura_id': legislaturas.first().id, 'mandatos': Mandato.objects.all(), 'form': form, 'filiacao': Filiacao.objects.all()}) @@ -157,7 +158,7 @@ class ParlamentaresView(GenericView): def post(self, request, *args, **kwargs): form = ParlamentaresForm(request.POST) return self.render_to_response( - {'legislaturas': Legislatura.objects.all().order_by('-data_inicio'), + {'legislaturas': Legislatura.objects.all().order_by('-data_inicio','-data_fim'), 'legislatura_id': int(form.data['periodo']), 'mandatos': Mandato.objects.all(), 'form': form,