From a7b2bf44403aec65f58e7f71a7a09a91036bc86c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ses=C3=B3stris=20Vieira?= Date: Wed, 9 Aug 2023 10:29:26 -0300 Subject: [PATCH] =?UTF-8?q?Permitir=20exporta=C3=A7=C3=A3o=20das=20Unidade?= =?UTF-8?q?s=20Federativas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sigi/apps/contatos/admin.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/sigi/apps/contatos/admin.py b/sigi/apps/contatos/admin.py index f8f498c..a863a2e 100644 --- a/sigi/apps/contatos/admin.py +++ b/sigi/apps/contatos/admin.py @@ -12,6 +12,22 @@ from sigi.apps.contatos.models import ( ) from sigi.apps.parlamentares.models import Senador from sigi.apps.utils import queryset_ascii +from sigi.apps.utils.mixins import ( + ReturnMixin, + CartExportMixin, + LabeledResourse, +) + + +class UnidadeFederativaResource(LabeledResourse): + class Meta: + model = UnidadeFederativa + fields = ("codigo_ibge", "nome", "sigla", "regiao", "populacao") + export_order = fields + name = "Exportação de Unidades Federativas" + + def dehydrate_regiao(self, uf): + return dict(UnidadeFederativa.REGIAO_CHOICES)[uf.regiao] class MesorregiaoInline(admin.TabularInline): @@ -29,8 +45,9 @@ class SenadorInline(admin.StackedInline): @admin.register(UnidadeFederativa) -class UnidadeFederativaAdmin(admin.ModelAdmin): +class UnidadeFederativaAdmin(CartExportMixin, admin.ModelAdmin): actions = None + resource_classes = [UnidadeFederativaResource] list_display = ("codigo_ibge", "nome", "sigla", "regiao", "populacao") list_display_links = ("codigo_ibge", "nome") list_filter = (