Browse Source

Add "Clear all filters" option to all model admins

For that we use BaseModelAdmin in all model admins
producao
Marcio Mazza 10 years ago
parent
commit
efbb0ce990
  1. 3
      sigi/apps/casas/admin.py
  2. 10
      sigi/apps/contatos/admin.py
  3. 7
      sigi/apps/convenios/admin.py
  4. 6
      sigi/apps/diagnosticos/admin.py
  5. 3
      sigi/apps/financeiro/admin.py
  6. 13
      sigi/apps/inventario/admin.py
  7. 15
      sigi/apps/mesas/admin.py
  8. 6
      sigi/apps/metas/admin.py
  9. 3
      sigi/apps/ocorrencias/admin.py
  10. 4
      sigi/apps/parlamentares/admin.py
  11. 7
      sigi/apps/servicos/admin.py
  12. 9
      sigi/apps/servidores/admin.py

3
sigi/apps/casas/admin.py

@ -18,6 +18,7 @@ from sigi.apps.metas.models import PlanoDiretor
from sigi.apps.ocorrencias.models import Ocorrencia
from sigi.apps.servicos.models import Servico
from sigi.apps.utils import queryset_ascii
from sigi.apps.utils.base_admin import BaseModelAdmin
class TelefonesInline(generic.GenericTabularInline):
@ -159,7 +160,7 @@ class OcorrenciaInline(admin.TabularInline):
can_delete = False
class CasaLegislativaAdmin(ImageCroppingMixin, admin.ModelAdmin):
class CasaLegislativaAdmin(ImageCroppingMixin, BaseModelAdmin):
form = CasaLegislativaForm
actions = ['adicionar_casas', ]
inlines = (TelefonesInline, PresidenteInline, FuncionariosInline, ConveniosInline, LegislaturaInline,

10
sigi/apps/contatos/admin.py

@ -1,13 +1,13 @@
# -*- coding: utf-8 -*-
from django.contrib import admin
from sigi.apps.contatos.filters import PopulationFilter
from sigi.apps.contatos.models import (UnidadeFederativa, Municipio, Telefone,
Contato)
from sigi.apps.utils import queryset_ascii
from sigi.apps.utils.base_admin import BaseModelAdmin
class UnidadeFederativaAdmin(admin.ModelAdmin):
class UnidadeFederativaAdmin(BaseModelAdmin):
actions = None
list_display = ('codigo_ibge', 'nome', 'sigla', 'regiao', 'populacao')
list_display_links = ('codigo_ibge', 'nome')
@ -16,7 +16,7 @@ class UnidadeFederativaAdmin(admin.ModelAdmin):
get_queryset = queryset_ascii
class MunicipioAdmin(admin.ModelAdmin):
class MunicipioAdmin(BaseModelAdmin):
actions = None
list_display = ('codigo_ibge', 'codigo_tse', 'nome', 'uf', 'is_capital', 'populacao', 'is_polo', 'idh', 'pib_ano',
'pib_total', 'pib_percapita')
@ -37,7 +37,7 @@ class MunicipioAdmin(admin.ModelAdmin):
'codigo_microrregiao', 'uf__sigla')
class TelefoneAdmin(admin.ModelAdmin):
class TelefoneAdmin(BaseModelAdmin):
list_display = ('numero', 'tipo', 'nota')
list_display_links = ('numero',)
list_filter = ('tipo',)
@ -45,7 +45,7 @@ class TelefoneAdmin(admin.ModelAdmin):
search_fields = ('numero', 'tipo', 'nota')
class ContatoAdmin(admin.ModelAdmin):
class ContatoAdmin(BaseModelAdmin):
list_display = ('nome', 'nota', 'email', 'municipio')
list_display_links = ('nome',)
list_filter = ('nome',)

7
sigi/apps/convenios/admin.py

@ -7,6 +7,7 @@ from sigi.apps.convenios.models import Projeto, Convenio, EquipamentoPrevisto, A
from sigi.apps.convenios.reports import ConvenioReport
from sigi.apps.convenios.views import adicionar_convenios_carrinho
from sigi.apps.utils import queryset_ascii
from sigi.apps.utils.base_admin import BaseModelAdmin
class TramitacaoInline(admin.TabularInline):
@ -26,7 +27,7 @@ class EquipamentoPrevistoInline(admin.TabularInline):
raw_id_fields = ('equipamento',)
class AnexoAdmin(admin.ModelAdmin):
class AnexoAdmin(BaseModelAdmin):
date_hierarchy = 'data_pub'
exclude = ['data_pub', ]
list_display = ('arquivo', 'descricao', 'data_pub', 'convenio')
@ -35,7 +36,7 @@ class AnexoAdmin(admin.ModelAdmin):
'convenio__casa_legislativa__nome')
class ConvenioAdmin(admin.ModelAdmin):
class ConvenioAdmin(BaseModelAdmin):
change_list_template = 'convenios/change_list.html'
fieldsets = (
(None,
@ -130,7 +131,7 @@ class ConvenioAdmin(admin.ModelAdmin):
lookup in ['casa_legislativa__municipio__uf__codigo_ibge__exact']
class EquipamentoPrevistoAdmin(admin.ModelAdmin):
class EquipamentoPrevistoAdmin(BaseModelAdmin):
list_display = ('convenio', 'equipamento', 'quantidade')
list_display_links = ('convenio', 'equipamento')
ordering = ('convenio', 'equipamento')

6
sigi/apps/diagnosticos/admin.py

@ -3,9 +3,9 @@ from datetime import datetime
from django.contrib import admin
from django.db.utils import OperationalError, ProgrammingError
from eav.admin import BaseEntityAdmin, BaseSchemaAdmin
from sigi.apps.diagnosticos.forms import DiagnosticoForm
from sigi.apps.diagnosticos.models import Diagnostico, Pergunta, Escolha, Equipe, Anexo, Categoria
from sigi.apps.utils.base_admin import BaseModelAdmin
def publicar_diagnostico(self, request, queryset):
@ -40,7 +40,7 @@ class AnexosInline(admin.TabularInline):
exclude = ['data_pub', ]
class AnexoAdmin(admin.ModelAdmin):
class AnexoAdmin(BaseModelAdmin):
date_hierarchy = 'data_pub'
exclude = ['data_pub', ]
list_display = ('arquivo', 'descricao', 'data_pub', 'diagnostico')
@ -115,7 +115,7 @@ class DiagnosticoAdmin(BaseEntityAdmin):
return super(DiagnosticoAdmin, self).changelist_view(request, extra_context)
class EscolhaAdmin(admin.ModelAdmin):
class EscolhaAdmin(BaseModelAdmin):
search_fields = ('title',)
list_display = ('title', 'schema', 'schema_to_open')
raw_id_fields = ('schema', 'schema_to_open')

3
sigi/apps/financeiro/admin.py

@ -2,9 +2,10 @@
from django.contrib import admin
from sigi.apps.financeiro.models import Desembolso
from sigi.apps.utils.base_admin import BaseModelAdmin
class DesembolsoAdmin(admin.ModelAdmin):
class DesembolsoAdmin(BaseModelAdmin):
list_display = ('projeto', 'descricao', 'data', 'valor_reais', 'valor_dolar',)
fields = ('projeto', 'descricao', 'data', 'valor_reais', 'valor_dolar', )
list_filter = ('projeto',)

13
sigi/apps/inventario/admin.py

@ -6,6 +6,7 @@ from sigi.apps.contatos.models import Contato, Telefone
from sigi.apps.inventario.models import (Fornecedor, Fabricante, Equipamento,
TipoEquipamento, ModeloEquipamento,
Bem)
from sigi.apps.utils.base_admin import BaseModelAdmin
class ContatosInline(generic.GenericTabularInline):
@ -19,7 +20,7 @@ class TelefonesInline(generic.GenericTabularInline):
extra = 2
class FornecedorAdmin(admin.ModelAdmin):
class FornecedorAdmin(BaseModelAdmin):
inlines = (TelefonesInline, ContatosInline)
list_display = ('id', 'nome', 'email', 'pagina_web')
list_display_links = ('id', 'nome')
@ -27,21 +28,21 @@ class FornecedorAdmin(admin.ModelAdmin):
search_fields = ('id', 'nome', 'email', 'pagina_web')
class FabricanteAdmin(admin.ModelAdmin):
class FabricanteAdmin(BaseModelAdmin):
list_display = ('id', 'nome')
list_display_links = list_display
list_filter = ('nome',)
search_fields = ('id', 'nome')
class TipoEquipamentoAdmin(admin.ModelAdmin):
class TipoEquipamentoAdmin(BaseModelAdmin):
list_display = ('id', 'tipo')
list_display_links = list_display
list_filter = ('tipo',)
search_fields = ('id', 'tipo')
class ModeloEquipamentoAdmin(admin.ModelAdmin):
class ModeloEquipamentoAdmin(BaseModelAdmin):
list_display = ('id', 'tipo', 'modelo')
list_filter = ('tipo', 'modelo')
ordering = ('tipo', 'modelo')
@ -49,7 +50,7 @@ class ModeloEquipamentoAdmin(admin.ModelAdmin):
raw_id_fields = ('tipo',)
class EquipamentoAdmin(admin.ModelAdmin):
class EquipamentoAdmin(BaseModelAdmin):
list_display = ('id', 'fabricante', 'modelo', 'get_tipo')
list_display_links = ('id',)
list_filter = ('fabricante',)
@ -62,7 +63,7 @@ class EquipamentoAdmin(admin.ModelAdmin):
get_tipo.short_description = 'tipo'
class BemAdmin(admin.ModelAdmin):
class BemAdmin(BaseModelAdmin):
list_display = ('equipamento', 'fornecedor', 'num_serie',
'casa_legislativa')
list_filter = ('fornecedor',)

15
sigi/apps/mesas/admin.py

@ -7,6 +7,7 @@ from sigi.apps.mesas.models import (Legislatura, Coligacao, ComposicaoColigacao,
SessaoLegislativa, MesaDiretora, Cargo,
MembroMesaDiretora)
from sigi.apps.parlamentares.models import Mandato
from sigi.apps.utils.base_admin import BaseModelAdmin
class MandatoInline(admin.TabularInline):
@ -14,7 +15,7 @@ class MandatoInline(admin.TabularInline):
raw_id_fields = ['parlamentar', ]
class LegislaturaAdmin(admin.ModelAdmin):
class LegislaturaAdmin(BaseModelAdmin):
date_hierarchy = 'data_inicio'
list_display = ('numero', 'casa_legislativa', 'uf', 'data_inicio', 'data_fim', 'data_eleicao', 'total_parlamentares')
raw_id_fields = ('casa_legislativa',)
@ -41,14 +42,14 @@ class LegislaturaAdmin(admin.ModelAdmin):
return response
class ColigacaoAdmin(admin.ModelAdmin):
class ColigacaoAdmin(BaseModelAdmin):
list_display = ('nome', 'legislatura', 'numero_votos')
list_display_links = ('nome',)
raw_id_fields = ('legislatura',)
search_fields = ('nome', 'legislatura__numero')
class ComposicaoColigacaoAdmin(admin.ModelAdmin):
class ComposicaoColigacaoAdmin(BaseModelAdmin):
list_display = ('coligacao', 'partido')
list_display_links = ('coligacao', 'partido')
list_filter = ('partido',)
@ -56,7 +57,7 @@ class ComposicaoColigacaoAdmin(admin.ModelAdmin):
search_fields = ('coligacao__nome', 'partido__nome', 'partido__sigla')
class SessaoLegislativaAdmin(admin.ModelAdmin):
class SessaoLegislativaAdmin(BaseModelAdmin):
list_display = ('numero', 'mesa_diretora', 'legislatura', 'tipo',
'data_inicio', 'data_fim')
list_display_links = ('numero',)
@ -75,7 +76,7 @@ class SessaoLegislativaAdmin(admin.ModelAdmin):
search_fields = ('numero', 'mesa_diretora__casa_legislativa__nome')
class CargoAdmin(admin.ModelAdmin):
class CargoAdmin(BaseModelAdmin):
list_display = ('descricao',)
search_fields = ('descricao',)
@ -87,7 +88,7 @@ class MembroMesaDiretoraInline(admin.TabularInline):
raw_id_fields = ('parlamentar', 'cargo')
class MembroMesaDiretoraAdmin(admin.ModelAdmin):
class MembroMesaDiretoraAdmin(BaseModelAdmin):
list_display = ('parlamentar', 'cargo', 'mesa_diretora')
list_display_links = ('parlamentar',)
list_filter = ('cargo',)
@ -97,7 +98,7 @@ class MembroMesaDiretoraAdmin(admin.ModelAdmin):
'mesa_diretora__casa_legislativa__nome')
class MesaDiretoraAdmin(admin.ModelAdmin):
class MesaDiretoraAdmin(BaseModelAdmin):
inlines = (MembroMesaDiretoraInline,)
raw_id_fields = ('casa_legislativa',)
list_display = ('id', 'casa_legislativa')

6
sigi/apps/metas/admin.py

@ -2,15 +2,15 @@
from django.contrib import admin
from sigi.apps.metas.models import PlanoDiretor
from sigi.apps.utils.base_admin import BaseModelAdmin
class MetaAdmin(admin.ModelAdmin):
class MetaAdmin(BaseModelAdmin):
list_display = ('projeto', 'titulo', 'data_inicio', 'data_fim', 'valor_meta', 'valor_executado', 'percentual_concluido',)
fields = ('projeto', 'titulo', 'descricao', 'data_inicio', 'data_fim', 'algoritmo', 'valor_meta',)
list_filter = ('projeto',)
class PlanoDiretorAdmin(admin.ModelAdmin):
class PlanoDiretorAdmin(BaseModelAdmin):
list_display = ('projeto', 'casa_legislativa', 'get_uf', 'status', 'data_entrega', 'data_implantacao',)
fields = ('projeto', 'casa_legislativa', 'status', 'data_entrega', 'data_implantacao',)
raw_id_fields = ('casa_legislativa',)

3
sigi/apps/ocorrencias/admin.py

@ -5,6 +5,7 @@ from django.contrib.admin.views.main import ChangeList
from filters import OcorrenciaListFilter
from sigi.apps.ocorrencias.models import Ocorrencia, Comentario, Anexo, Categoria, TipoContato
from sigi.apps.servidores.models import Servidor
from sigi.apps.utils.base_admin import BaseModelAdmin
class ComentarioViewInline(admin.TabularInline):
@ -59,7 +60,7 @@ class OcorrenciaChangeList(ChangeList):
qs = qs.filter(servidor_registro=servidor)
return qs
class OcorrenciaAdmin(admin.ModelAdmin):
class OcorrenciaAdmin(BaseModelAdmin):
list_display = ('data_criacao', 'casa_legislativa', 'get_municipio', 'get_uf', 'assunto', 'prioridade', 'status', 'data_modificacao', 'setor_responsavel',)
list_filter = (OcorrenciaListFilter, 'status', 'prioridade', 'categoria__nome', 'setor_responsavel__nome', )
search_fields = ('casa_legislativa__search_text', 'assunto', 'servidor_registro__nome_completo', )

4
sigi/apps/parlamentares/admin.py

@ -21,7 +21,7 @@ class TelefonesInline(generic.GenericTabularInline):
extra = 2
class PartidoAdmin(admin.ModelAdmin):
class PartidoAdmin(BaseModelAdmin):
list_display = ('nome', 'sigla')
list_display_links = ('nome', 'sigla')
search_fields = ('nome', 'sigla')
@ -71,7 +71,7 @@ class ParlamentarAdmin(BaseModelAdmin):
adiciona_parlamentar.short_description = u"Armazenar parlamentar no carrinho para exportar"
class MandatoAdmin(admin.ModelAdmin):
class MandatoAdmin(BaseModelAdmin):
list_display = ('parlamentar', 'legislatura', 'partido',
'inicio_mandato', 'fim_mandato', 'is_afastado')
list_filter = ('is_afastado', 'partido')

7
sigi/apps/servicos/admin.py

@ -9,6 +9,7 @@ from django.utils.translation import ugettext as _
from sigi.apps.casas.admin import FuncionariosInline
from sigi.apps.casas.models import CasaLegislativa
from sigi.apps.servicos.models import Servico, LogServico, CasaAtendida, TipoServico
from sigi.apps.utils.base_admin import BaseModelAdmin
class LogServicoInline(admin.StackedInline):
@ -44,12 +45,12 @@ class ServicoFormAdmin(ModelForm):
self.fields['contato_administrativo'].choices = contatos
class TipoServicoAdmin(admin.ModelAdmin):
class TipoServicoAdmin(BaseModelAdmin):
list_display = ('id', 'sigla', 'nome', 'qtde_casas_atendidas', )
ordering = ['id']
class ServicoAdmin(admin.ModelAdmin):
class ServicoAdmin(BaseModelAdmin):
form = ServicoFormAdmin
actions = ['calcular_data_uso', ]
list_display = ('casa_legislativa', 'get_codigo_interlegis', 'get_uf', 'tipo_servico', 'hospedagem_interlegis',
@ -171,7 +172,7 @@ class ContatosInline(FuncionariosInline):
can_delete = False # Equipe do SEIT não pode excluir pessoas de contato
class CasaAtendidaAdmin(admin.ModelAdmin):
class CasaAtendidaAdmin(BaseModelAdmin):
actions = None
list_display = ('codigo_interlegis', 'nome', 'get_servicos',)
ordering = ['nome']

9
sigi/apps/servidores/admin.py

@ -6,10 +6,11 @@ from sigi.apps.contatos.models import Endereco, Telefone
from sigi.apps.servidores.forms import FeriasForm, LicencaForm, FuncaoForm
from sigi.apps.servidores.models import Servidor, Funcao, Licenca, Ferias, Servico, Subsecretaria
from sigi.apps.utils.admin_widgets import AdminImageWidget
from sigi.apps.utils.base_admin import BaseModelAdmin
from sigi.apps.utils.filters import AlphabeticFilter
class FuncaoAdmin(admin.ModelAdmin):
class FuncaoAdmin(BaseModelAdmin):
form = FuncaoForm
list_display = ('servidor', 'funcao', 'cargo', 'inicio_funcao', 'fim_funcao')
list_filter = ('inicio_funcao', 'fim_funcao')
@ -19,7 +20,7 @@ class FuncaoAdmin(admin.ModelAdmin):
'servidor__user__last_name', 'servidor__user__username')
class FeriasAdmin(admin.ModelAdmin):
class FeriasAdmin(BaseModelAdmin):
form = FeriasForm
list_display = ('servidor', 'inicio_ferias', 'fim_ferias')
list_filter = ('inicio_ferias', 'fim_ferias')
@ -33,7 +34,7 @@ class ServidorFilter(AlphabeticFilter):
parameter_name = 'servidor__nome_completo'
class LicencaAdmin(admin.ModelAdmin):
class LicencaAdmin(BaseModelAdmin):
form = LicencaForm
list_display = ('servidor', 'inicio_licenca', 'fim_licenca')
list_filter = (ServidorFilter, 'inicio_licenca', 'fim_licenca')
@ -57,7 +58,7 @@ class TelefonesInline(generic.GenericTabularInline):
model = Telefone
class ServidorAdmin(admin.ModelAdmin):
class ServidorAdmin(BaseModelAdmin):
def is_active(self, servidor):
return servidor.user.is_active

Loading…
Cancel
Save