From ca2a570e8c8bd341637655071f5f42e0d2de8aea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ses=C3=B3stris=20Vieira?= Date: Wed, 23 Oct 2013 10:34:16 -0200 Subject: [PATCH] =?UTF-8?q?Acrescentado=20respons=C3=A1vel=20administrativ?= =?UTF-8?q?o=20na=20lista=20de=20servi=C3=A7os=20da=20administra=C3=A7?= =?UTF-8?q?=C3=A3o=20das=20Casas=20Atendidas.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A função que formata a informação foi movida do Model CasaAtendida para a classe CasaAtendidaAdmin pois sua tarefa é apenas de apresentação, sendo mais correto estar vinculado ao Admin e não ao Model. --- sigi/apps/servicos/admin.py | 12 +++++++++++- sigi/apps/servicos/models.py | 8 -------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/sigi/apps/servicos/admin.py b/sigi/apps/servicos/admin.py index 74442ea..665ddf4 100644 --- a/sigi/apps/servicos/admin.py +++ b/sigi/apps/servicos/admin.py @@ -169,7 +169,7 @@ class ContatosInline(FuncionariosInline): class CasaAtendidaAdmin(admin.ModelAdmin): actions = None - list_display = ('codigo_interlegis', 'nome', 'servicos',) + list_display = ('codigo_interlegis', 'nome', 'get_servicos',) ordering = ['nome'] fieldsets = ( ('Casa legislativa', { @@ -182,6 +182,16 @@ class CasaAtendidaAdmin(admin.ModelAdmin): search_fields = ('search_text','cnpj', 'bairro', 'logradouro', 'cep', 'municipio__nome', 'municipio__uf__nome', 'municipio__codigo_ibge', 'pagina_web', 'observacoes') + + def get_servicos(self, obj): + result = [] + for servico in obj.servico_set.all(): + result.append(u"%s (%s). Contato: %s" % (servico.tipo_servico.nome, 'ativo' if servico.data_desativacao is None + else 'Desativado', servico.contato_administrativo.nome)) + + return "" + get_servicos.allow_tags = True + get_servicos.short_description = u"Serviços" def lookup_allowed(self, lookup, value): return super(CasaAtendidaAdmin, self).lookup_allowed(lookup, value) or \ diff --git a/sigi/apps/servicos/models.py b/sigi/apps/servicos/models.py index 7e4b688..9f4bcce 100644 --- a/sigi/apps/servicos/models.py +++ b/sigi/apps/servicos/models.py @@ -179,14 +179,6 @@ class CasaAtendida(CasaLegislativa): objects = CasaAtendidaManager() - @property - def servicos(self): - result = [] - for servico in self.servico_set.all(): - result.append(unicode(servico)) - - return ", ".join(result) - class CasaManifesta(models.Model): casa_legislativa = models.OneToOneField(CasaLegislativa) data_manifestacao = models.DateTimeField(auto_now_add=True)