From c1753db3c56b547e5fe0b5992c9febf37caca7da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ses=C3=B3stris=20Vieira?= Date: Wed, 9 Aug 2023 11:42:27 -0300 Subject: [PATCH] =?UTF-8?q?Permitir=20exporta=C3=A7=C3=A3o=20de=20munic?= =?UTF-8?q?=C3=ADpios?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sigi/apps/contatos/admin.py | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/sigi/apps/contatos/admin.py b/sigi/apps/contatos/admin.py index a863a2e..2710e8b 100644 --- a/sigi/apps/contatos/admin.py +++ b/sigi/apps/contatos/admin.py @@ -30,6 +30,36 @@ class UnidadeFederativaResource(LabeledResourse): return dict(UnidadeFederativa.REGIAO_CHOICES)[uf.regiao] +class MunicipioResource(LabeledResourse): + class Meta: + model = Municipio + fields = ( + "codigo_ibge", + "codigo_tse", + "nome", + "uf__regiao", + "uf__sigla", + "uf__nome", + "microrregiao__mesorregiao__nome", + "microrregiao__nome", + "is_capital", + "populacao", + "is_polo", + "data_criacao", + "latitude", + "longitude", + "idh", + "pib_total", + "pib_percapita", + "pib_ano", + ) + export_order = fields + name = "Exportação de Municípios" + + def dehydrate_uf__regiao(self, municipio): + return dict(UnidadeFederativa.REGIAO_CHOICES)[municipio.uf.regiao] + + class MesorregiaoInline(admin.TabularInline): model = Mesorregiao @@ -82,8 +112,9 @@ class MicrorregiaoAdmin(admin.ModelAdmin): @admin.register(Municipio) -class MunicipioAdmin(admin.ModelAdmin): +class MunicipioAdmin(CartExportMixin, admin.ModelAdmin): actions = None + resource_classes = [MunicipioResource] list_display = ( "codigo_ibge", "codigo_tse",