diff --git a/sigi/apps/casas/admin.py b/sigi/apps/casas/admin.py index ff24599..0564a6d 100644 --- a/sigi/apps/casas/admin.py +++ b/sigi/apps/casas/admin.py @@ -8,8 +8,8 @@ from sigi.apps.convenios.models import Projeto, Convenio, EquipamentoPrevisto, A from django.http import HttpResponse, HttpResponseRedirect from sigi.apps.casas.reports import CasasLegislativasLabels, CasasLegislativasReport from geraldo.generators import PDFGenerator - from sigi.apps.casas.views import casa_info, labels_report +from sigi.apps.utils import queryset_ascii class ContatosInline(generic.GenericTabularInline): model = Contato @@ -35,6 +35,7 @@ class CasaLegislativaAdmin(admin.ModelAdmin): list_display_links = ('nome',) list_filter = ('tipo', 'municipio') ordering = ('nome','municipio__uf') + queyrset = queryset_ascii fieldsets = ( (None, { 'fields': ('tipo', 'nome', 'telefone', 'cnpj', @@ -49,7 +50,7 @@ class CasaLegislativaAdmin(admin.ModelAdmin): }), ) raw_id_fields = ('municipio',) - search_fields = ('nome','cnpj', 'logradouro', 'bairro', + search_fields = ('search_text','cnpj', 'bairro', 'logradouro', 'cep', 'municipio__nome', 'municipio__uf__nome', 'municipio__codigo_ibge', 'pagina_web', 'observacoes') diff --git a/sigi/apps/casas/models.py b/sigi/apps/casas/models.py index 21b55b8..77f3d2f 100644 --- a/sigi/apps/casas/models.py +++ b/sigi/apps/casas/models.py @@ -3,6 +3,7 @@ from django.db import models from django.contrib.contenttypes import generic from sigi.apps.mesas.models import MesaDiretora, MembroMesaDiretora from sigi.apps.parlamentares.models import Parlamentar +from sigi.apps.utils import SearchField class TipoCasaLegislativa(models.Model): sigla = models.CharField( @@ -20,6 +21,7 @@ class CasaLegislativa(models.Model): max_length=60, help_text='Exemplo: Câmara Municipal de Pains.' ) + search_text = SearchField(field_names=['nome']) tipo = models.ForeignKey(TipoCasaLegislativa, verbose_name="Tipo") cnpj = models.CharField('CNPJ', max_length=32, blank=True) observacoes = models.TextField(u'observações', blank=True) diff --git a/sigi/apps/contatos/admin.py b/sigi/apps/contatos/admin.py index 3dd46e7..8c2a670 100644 --- a/sigi/apps/contatos/admin.py +++ b/sigi/apps/contatos/admin.py @@ -2,19 +2,22 @@ from django.contrib import admin from sigi.apps.contatos.models import (UnidadeFederativa, Municipio, Telefone, Contato) +from sigi.apps.utils import queryset_ascii class UnidadeFederativaAdmin(admin.ModelAdmin): actions = None list_display = ('codigo_ibge', 'nome', 'sigla', 'regiao', 'populacao') list_display_links = ('codigo_ibge', 'nome') list_filter = ('regiao', 'populacao') - search_fields = ('codigo_ibge', 'nome', 'sigla', 'regiao') + search_fields = ('search_text', 'codigo_ibge', 'sigla', 'regiao') + queryset = queryset_ascii class MunicipioAdmin(admin.ModelAdmin): actions = None list_display = ('codigo_ibge', 'codigo_tse', 'nome', 'uf', 'is_capital', 'populacao', 'is_polo') list_display_links = ('codigo_ibge', 'codigo_tse', 'nome') list_filter = ('is_capital', 'is_polo', 'populacao', 'uf') + queryset = queryset_ascii fieldsets = ( (None, { 'fields': ('codigo_ibge', 'codigo_tse', 'codigo_mesorregiao', @@ -25,8 +28,8 @@ class MunicipioAdmin(admin.ModelAdmin): 'fields': ('latitude', 'longitude'), }), ) - search_fields = ('codigo_ibge', 'codigo_tse', 'codigo_mesorregiao', - 'codigo_microrregiao', 'nome', 'uf__nome', 'uf__sigla') + search_fields = ('search_text', 'codigo_ibge', 'codigo_tse', 'codigo_mesorregiao', + 'codigo_microrregiao', 'uf__sigla') class TelefoneAdmin(admin.ModelAdmin): list_display = ('codigo_area', 'numero', 'tipo', 'nota') diff --git a/sigi/apps/contatos/models.py b/sigi/apps/contatos/models.py index 6c725b2..75c8191 100644 --- a/sigi/apps/contatos/models.py +++ b/sigi/apps/contatos/models.py @@ -2,6 +2,7 @@ from django.db import models from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes import generic +from sigi.apps.utils import SearchField class UnidadeFederativa(models.Model): REGIAO_CHOICES = ( @@ -18,6 +19,7 @@ class UnidadeFederativa(models.Model): help_text='Código do estado segundo IBGE.' ) nome = models.CharField(max_length=25) + search_text = SearchField(field_names=['nome']) sigla = models.CharField( max_length=2, unique=True, @@ -59,6 +61,7 @@ class Municipio(models.Model): help_text='Código do município segundo TSE.' ) nome = models.CharField(max_length=50) + search_text = SearchField(field_names=['nome', 'uf']) uf = models.ForeignKey(UnidadeFederativa, verbose_name='UF') is_capital = models.BooleanField('capital') populacao = models.PositiveIntegerField(u'população') diff --git a/sigi/apps/convenios/admin.py b/sigi/apps/convenios/admin.py index bc0f87f..9b8bcdc 100644 --- a/sigi/apps/convenios/admin.py +++ b/sigi/apps/convenios/admin.py @@ -5,6 +5,7 @@ from sigi.apps.casas.models import CasaLegislativa from sigi.apps.servicos.models import Servico from django.http import HttpResponse, HttpResponseRedirect from sigi.apps.convenios.reports import ConvenioReport +from sigi.apps.utils import queryset_ascii from geraldo.generators import PDFGenerator class AnexosInline(admin.TabularInline): @@ -48,7 +49,8 @@ class ConvenioAdmin(admin.ModelAdmin): #date_hierarchy = 'data_adesao' ordering = ('casa_legislativa__municipio__uf','-id',) raw_id_fields = ('casa_legislativa',) - search_fields = ('id', 'casa_legislativa__nome', + queryset = queryset_ascii + search_fields = ('id', 'search_text',#'casa_legislativa__nome', 'num_processo_sf','num_convenio') def changelist_view(self, request, extra_context=None): diff --git a/sigi/apps/convenios/models.py b/sigi/apps/convenios/models.py index 8d92f29..2407483 100644 --- a/sigi/apps/convenios/models.py +++ b/sigi/apps/convenios/models.py @@ -3,6 +3,7 @@ from datetime import datetime from django.db import models #from django.contrib.contenttypes import ContentType from django.contrib.contenttypes import generic +from sigi.apps.utils import SearchField class Projeto(models.Model): nome = models.CharField(max_length=50) @@ -16,6 +17,7 @@ class Convenio(models.Model): 'casas.CasaLegislativa', verbose_name='Casa Legislativa' ) + search_text = SearchField(field_names=['casa_legislativa']) casa_legislativa.convenio_uf_filter = True casa_legislativa.convenio_cl_tipo_filter = True projeto = models.ForeignKey(