From 620378ed1fb96d736b77f641ee17ba347ba2b30a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ses=C3=B3stris=20Vieira?= Date: Tue, 18 Dec 2012 15:34:32 -0200 Subject: [PATCH] =?UTF-8?q?Corre=C3=A7=C3=A3o=20da=20classe=20mesas.Legisl?= =?UTF-8?q?atura=20para=20registrar=20as=20legislaturas=20e=20o=20n=C3=BAm?= =?UTF-8?q?ero=20de=20parlamentares=20por=20Casa=20Legislativa?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sigi/apps/mesas/admin.py | 12 +++++++++--- sigi/apps/mesas/models.py | 9 +++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/sigi/apps/mesas/admin.py b/sigi/apps/mesas/admin.py index 2b0f413..5267db0 100644 --- a/sigi/apps/mesas/admin.py +++ b/sigi/apps/mesas/admin.py @@ -6,10 +6,16 @@ from sigi.apps.mesas.models import (Legislatura, Coligacao, ComposicaoColigacao, class LegislaturaAdmin(admin.ModelAdmin): date_hierarchy = 'data_inicio' - list_display = ('numero', 'data_inicio', 'data_fim', 'data_eleicao') + list_display = ('casa_legislativa', 'numero', 'data_inicio', 'data_fim', 'data_eleicao', 'total_parlamentares') + raw_id_fields = ('casa_legislativa',) list_display_links = ('numero',) - list_filter = ('data_eleicao',) - search_fields = ('numero',) + list_filter = ('casa_legislativa', 'data_eleicao',) + search_fields = ('numero', 'casa_legislativa') + + def lookup_allowed(self, lookup, value): + return super(LegislaturaAdmin, self).lookup_allowed(lookup, value) or \ + lookup in ['casa_legislativa__municipio__uf__codigo_ibge__exact'] + class ColigacaoAdmin(admin.ModelAdmin): list_display = ('nome', 'legislatura', 'numero_votos') diff --git a/sigi/apps/mesas/models.py b/sigi/apps/mesas/models.py index efe0e1d..c5f65e6 100644 --- a/sigi/apps/mesas/models.py +++ b/sigi/apps/mesas/models.py @@ -1,11 +1,20 @@ # -*- coding: utf-8 -*- from django.db import models +from sigi.apps.casas.models import CasaLegislativa class Legislatura(models.Model): + casa_legislativa = models.ForeignKey(CasaLegislativa) numero = models.PositiveSmallIntegerField(u'número legislatura') data_inicio = models.DateField(u'início') data_fim = models.DateField('fim') data_eleicao = models.DateField(u'data da eleição') + total_parlamentares = models.PositiveIntegerField(u"Total de parlamentares") + + casa_legislativa.convenio_uf_filter = True + casa_legislativa.convenio_cl_tipo_filter = True + + def meta(self): + unique_together = (('casa_legislativa', 'numero')) def __unicode__(self): return str(self.numero)