From 71a5e79fabc08e207c3627684befee778880c0c7 Mon Sep 17 00:00:00 2001 From: Sesostris Vieira Date: Wed, 9 May 2012 19:27:14 +0000 Subject: [PATCH] =?UTF-8?q?Acrescentando=20campo=20UF=20na=20changelist=20?= =?UTF-8?q?dos=20diagn=C3=B3sticos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sigi/apps/diagnosticos/admin.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/sigi/apps/diagnosticos/admin.py b/sigi/apps/diagnosticos/admin.py index 2ac96ef..746119a 100644 --- a/sigi/apps/diagnosticos/admin.py +++ b/sigi/apps/diagnosticos/admin.py @@ -4,11 +4,8 @@ from django.contrib import admin from eav.admin import BaseEntityAdmin, BaseSchemaAdmin from sigi.apps.diagnosticos.models import Diagnostico, Pergunta, Escolha, Equipe, Anexo, Categoria from sigi.apps.diagnosticos.forms import DiagnosticoForm +from sigi.apps.contatos.models import UnidadeFederativa - -""" -Actions do Admin -""" def publicar_diagnostico(self, request, queryset): for registro in queryset: diagnostico = Diagnostico.objects.get(pk=registro.id) @@ -30,7 +27,6 @@ def despublicar_diagnostico(self, request, queryset): despublicar_diagnostico.short_description = u""" Definir diagnósticos como não publicado""" - class EquipeInline(admin.TabularInline): model = Equipe @@ -39,7 +35,6 @@ class AnexosInline(admin.TabularInline): extra = 2 exclude = ['data_pub', ] - class AnexoAdmin(admin.ModelAdmin): date_hierarchy = 'data_pub' exclude = ['data_pub', ] @@ -48,13 +43,12 @@ class AnexoAdmin(admin.ModelAdmin): search_fields = ('descricao', 'diagnostico__id', 'arquivo', 'diagnostico__casa_legislativa__nome') - class DiagnosticoAdmin(BaseEntityAdmin): form = DiagnosticoForm actions = [publicar_diagnostico, despublicar_diagnostico] inlines = (EquipeInline, AnexosInline) search_fields = ('casa_legislativa__nome', 'responsavel',) - list_display = ('casa_legislativa', 'data_visita_inicio', 'data_visita_fim', 'responsavel', 'publicado') + list_display = ('casa_legislativa','getUf', 'data_visita_inicio', 'data_visita_fim', 'responsavel', 'publicado') list_filter = ('publicado', 'data_publicacao', 'data_visita_inicio', 'data_visita_fim') raw_id_fields = ('casa_legislativa',) @@ -76,6 +70,11 @@ class DiagnosticoAdmin(BaseEntityAdmin): 'classes': ['collapse'] })) + def getUf(self, obj): + return '%s' % (obj.casa_legislativa.municipio.uf) + + getUf.short_description = 'UF' + class EscolhaAdmin(admin.ModelAdmin): search_fields = ('title',) list_display = ('title', 'schema', 'schema_to_open')