From f86bd35b69c6ad71f05b20dadaecae5089702572 Mon Sep 17 00:00:00 2001 From: Felipe Vieira Date: Fri, 3 Feb 2012 12:35:27 +0000 Subject: [PATCH] resolvido o bug de etiqueta (permanece bug com telefone no caso do csv) --- sigi/apps/casas/models.py | 13 +++++++++++-- sigi/apps/casas/views.py | 4 ++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/sigi/apps/casas/models.py b/sigi/apps/casas/models.py index 8f26838..31d5e45 100644 --- a/sigi/apps/casas/models.py +++ b/sigi/apps/casas/models.py @@ -72,6 +72,13 @@ class CasaLegislativa(models.Model): verbose_name = 'Casa Legislativa' verbose_name_plural = 'Casas Legislativas' + @property + def presidente(self): + try: + return self.funcionario_set.get(setor='presidente') + except Funcionario.DoesNotExist: + return None + def __unicode__(self): return self.nome @@ -114,7 +121,7 @@ class Funcionario(models.Model): class PresidenteManager(models.Manager): def get_query_set(self): qs = super(PresidenteManager, self).get_query_set() - qs = qs.filter(cargo='Presidente') + qs = qs.filter(setor='presidente') return qs class Presidente(Funcionario): @@ -124,6 +131,8 @@ class Presidente(Funcionario): objects = PresidenteManager() def save(self, *args, **kwargs): + self.setor = 'presidente' self.cargo = 'Presidente' - self.setor = 'presidencia' + self.funcao = 'Presidente' return super(Presidente, self).save(*args, **kwargs) + diff --git a/sigi/apps/casas/views.py b/sigi/apps/casas/views.py index 2bccf1c..4a1978d 100644 --- a/sigi/apps/casas/views.py +++ b/sigi/apps/casas/views.py @@ -17,7 +17,7 @@ from django.conf import settings import csv def query_ordena(qs,o,ot): - list_display = ('nome','municipio','presidente','logradouro') + list_display = ('nome','municipio','logradouro') aux = list_display[(int(o)-1)] if ot =='asc': @@ -273,7 +273,7 @@ def export_csv(request): elif u"MunicĂ­pio" == atributo: lista.append(str(casa.municipio)) elif u"Presidente" == atributo: - lista.append(casa.presidente.encode("utf-8")) + lista.append(str(casa.presidente).encode("utf-8")) elif u"Logradouro" == atributo: lista.append(casa.logradouro.encode("utf-8")) elif u"Bairro" == atributo: