|
@ -1,6 +1,6 @@ |
|
|
|
|
|
from admin_auto_filters.filters import AutocompleteFilter |
|
|
from django.contrib import admin |
|
|
from django.contrib import admin |
|
|
from django.utils.translation import gettext as _ |
|
|
from django.utils.translation import gettext as _ |
|
|
|
|
|
|
|
|
from sigi.apps.utils.filters import RangeFilter |
|
|
from sigi.apps.utils.filters import RangeFilter |
|
|
from sigi.apps.contatos.models import ( |
|
|
from sigi.apps.contatos.models import ( |
|
|
UnidadeFederativa, |
|
|
UnidadeFederativa, |
|
@ -11,7 +11,7 @@ from sigi.apps.contatos.models import ( |
|
|
Contato, |
|
|
Contato, |
|
|
) |
|
|
) |
|
|
from sigi.apps.parlamentares.models import Senador |
|
|
from sigi.apps.parlamentares.models import Senador |
|
|
from sigi.apps.utils import queryset_ascii |
|
|
from sigi.apps.utils.mixins import AsciifyQParameter |
|
|
from sigi.apps.utils.mixins import ( |
|
|
from sigi.apps.utils.mixins import ( |
|
|
ReturnMixin, |
|
|
ReturnMixin, |
|
|
CartExportMixin, |
|
|
CartExportMixin, |
|
@ -19,6 +19,11 @@ from sigi.apps.utils.mixins import ( |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class MicrorregiaoFilter(AutocompleteFilter): |
|
|
|
|
|
title = _("Microrregião") |
|
|
|
|
|
field_name = "microrregiao" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class UnidadeFederativaResource(LabeledResourse): |
|
|
class UnidadeFederativaResource(LabeledResourse): |
|
|
class Meta: |
|
|
class Meta: |
|
|
model = UnidadeFederativa |
|
|
model = UnidadeFederativa |
|
@ -75,7 +80,9 @@ class SenadorInline(admin.StackedInline): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@admin.register(UnidadeFederativa) |
|
|
@admin.register(UnidadeFederativa) |
|
|
class UnidadeFederativaAdmin(CartExportMixin, admin.ModelAdmin): |
|
|
class UnidadeFederativaAdmin( |
|
|
|
|
|
AsciifyQParameter, CartExportMixin, admin.ModelAdmin |
|
|
|
|
|
): |
|
|
actions = None |
|
|
actions = None |
|
|
resource_classes = [UnidadeFederativaResource] |
|
|
resource_classes = [UnidadeFederativaResource] |
|
|
list_display = ("codigo_ibge", "nome", "sigla", "regiao", "populacao") |
|
|
list_display = ("codigo_ibge", "nome", "sigla", "regiao", "populacao") |
|
@ -85,12 +92,11 @@ class UnidadeFederativaAdmin(CartExportMixin, admin.ModelAdmin): |
|
|
("populacao", RangeFilter), |
|
|
("populacao", RangeFilter), |
|
|
) |
|
|
) |
|
|
search_fields = ("search_text", "codigo_ibge", "sigla", "regiao") |
|
|
search_fields = ("search_text", "codigo_ibge", "sigla", "regiao") |
|
|
get_queryset = queryset_ascii |
|
|
|
|
|
inlines = (SenadorInline, MesorregiaoInline) |
|
|
inlines = (SenadorInline, MesorregiaoInline) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@admin.register(Mesorregiao) |
|
|
@admin.register(Mesorregiao) |
|
|
class MesorregiaoAdmin(admin.ModelAdmin): |
|
|
class MesorregiaoAdmin(AsciifyQParameter, admin.ModelAdmin): |
|
|
actions = None |
|
|
actions = None |
|
|
list_display = ("codigo_ibge", "uf", "nome") |
|
|
list_display = ("codigo_ibge", "uf", "nome") |
|
|
list_display_links = ("codigo_ibge", "nome") |
|
|
list_display_links = ("codigo_ibge", "nome") |
|
@ -102,17 +108,16 @@ class MesorregiaoAdmin(admin.ModelAdmin): |
|
|
"uf__sigla", |
|
|
"uf__sigla", |
|
|
) |
|
|
) |
|
|
autocomplete_fields = ("uf",) |
|
|
autocomplete_fields = ("uf",) |
|
|
get_queryset = queryset_ascii |
|
|
|
|
|
inlines = (MicrorregiaoInline,) |
|
|
inlines = (MicrorregiaoInline,) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@admin.register(Microrregiao) |
|
|
@admin.register(Microrregiao) |
|
|
class MicrorregiaoAdmin(admin.ModelAdmin): |
|
|
class MicrorregiaoAdmin(AsciifyQParameter, admin.ModelAdmin): |
|
|
search_fields = ("search_text",) |
|
|
search_fields = ("search_text",) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@admin.register(Municipio) |
|
|
@admin.register(Municipio) |
|
|
class MunicipioAdmin(CartExportMixin, admin.ModelAdmin): |
|
|
class MunicipioAdmin(AsciifyQParameter, CartExportMixin, admin.ModelAdmin): |
|
|
actions = None |
|
|
actions = None |
|
|
resource_classes = [MunicipioResource] |
|
|
resource_classes = [MunicipioResource] |
|
|
list_display = ( |
|
|
list_display = ( |
|
@ -120,6 +125,8 @@ class MunicipioAdmin(CartExportMixin, admin.ModelAdmin): |
|
|
"codigo_tse", |
|
|
"codigo_tse", |
|
|
"nome", |
|
|
"nome", |
|
|
"uf", |
|
|
"uf", |
|
|
|
|
|
"get_regiao", |
|
|
|
|
|
"microrregiao", |
|
|
"is_capital", |
|
|
"is_capital", |
|
|
"populacao", |
|
|
"populacao", |
|
|
"is_polo", |
|
|
"is_polo", |
|
@ -136,8 +143,8 @@ class MunicipioAdmin(CartExportMixin, admin.ModelAdmin): |
|
|
("populacao", RangeFilter), |
|
|
("populacao", RangeFilter), |
|
|
"uf__regiao", |
|
|
"uf__regiao", |
|
|
"uf", |
|
|
"uf", |
|
|
|
|
|
MicrorregiaoFilter, |
|
|
) |
|
|
) |
|
|
get_queryset = queryset_ascii |
|
|
|
|
|
fieldsets = ( |
|
|
fieldsets = ( |
|
|
( |
|
|
( |
|
|
None, |
|
|
None, |
|
@ -169,6 +176,10 @@ class MunicipioAdmin(CartExportMixin, admin.ModelAdmin): |
|
|
autocomplete_fields = ("uf", "microrregiao") |
|
|
autocomplete_fields = ("uf", "microrregiao") |
|
|
search_fields = ("search_text", "codigo_ibge", "codigo_tse", "uf__sigla") |
|
|
search_fields = ("search_text", "codigo_ibge", "codigo_tse", "uf__sigla") |
|
|
|
|
|
|
|
|
|
|
|
@admin.display(description=_("Região"), ordering="uf__regiao") |
|
|
|
|
|
def get_regiao(self, obj): |
|
|
|
|
|
return obj.uf.get_regiao_display() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@admin.register(Telefone) |
|
|
@admin.register(Telefone) |
|
|
class TelefoneAdmin(admin.ModelAdmin): |
|
|
class TelefoneAdmin(admin.ModelAdmin): |
|
|