Browse Source

Adding a new filter

producao
Breno Teixeira 11 years ago
parent
commit
2c62cc04c4
  1. 19
      sigi/apps/servicos/admin.py

19
sigi/apps/servicos/admin.py

@ -1,7 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from django.contrib import admin from django.contrib import admin
from sigi.apps.servicos.models import Servico, LogServico, CasaAtendida, TipoServico from sigi.apps.servicos.models import Servico, LogServico, CasaAtendida, TipoServico
#from sigi.apps.casas.models import Funcionario
from sigi.apps.casas.admin import FuncionariosInline from sigi.apps.casas.admin import FuncionariosInline
from django.http import Http404, HttpResponseRedirect from django.http import Http404, HttpResponseRedirect
from django.forms.models import ModelForm from django.forms.models import ModelForm
@ -10,13 +9,13 @@ from django.utils.translation import ugettext as _
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from sigi.apps.casas.models import CasaLegislativa from sigi.apps.casas.models import CasaLegislativa
#---------------- inlines ---------------------
class LogServicoInline(admin.StackedInline): class LogServicoInline(admin.StackedInline):
model = LogServico model = LogServico
Fieldset = ((None, {'fields': (('data', 'descricao'), 'log')})) Fieldset = ((None, {'fields': (('data', 'descricao'), 'log')}))
extra = 1 extra = 1
# --------------- forms -----------------------
class ServicoFormAdmin(ModelForm): class ServicoFormAdmin(ModelForm):
class Meta: class Meta:
model = Servico model = Servico
@ -41,12 +40,13 @@ class ServicoFormAdmin(ModelForm):
contatos = [(f.id, unicode(f)) for f in casa.funcionario_set.all()] contatos = [(f.id, unicode(f)) for f in casa.funcionario_set.all()]
self.fields['contato_tecnico'].choices = contatos self.fields['contato_tecnico'].choices = contatos
self.fields['contato_administrativo'].choices = contatos self.fields['contato_administrativo'].choices = contatos
#---------------- admins ----------------------
class TipoServicoAdmin(admin.ModelAdmin): class TipoServicoAdmin(admin.ModelAdmin):
list_display = ('id', 'sigla', 'nome', 'qtde_casas_atendidas', ) list_display = ('id', 'sigla', 'nome', 'qtde_casas_atendidas', )
ordering = ['id'] ordering = ['id']
class ServicoAdmin(admin.ModelAdmin): class ServicoAdmin(admin.ModelAdmin):
form = ServicoFormAdmin form = ServicoFormAdmin
actions = ['calcular_data_uso',] actions = ['calcular_data_uso',]
@ -165,9 +165,11 @@ class ServicoAdmin(admin.ModelAdmin):
return obj return obj
class ContatosInline(FuncionariosInline): class ContatosInline(FuncionariosInline):
can_delete = False # Equipe do SEIT não pode excluir pessoas de contato can_delete = False # Equipe do SEIT não pode excluir pessoas de contato
class CasaAtendidaAdmin(admin.ModelAdmin): class CasaAtendidaAdmin(admin.ModelAdmin):
actions = None actions = None
list_display = ('codigo_interlegis', 'nome', 'get_servicos',) list_display = ('codigo_interlegis', 'nome', 'get_servicos',)
@ -179,7 +181,8 @@ class CasaAtendidaAdmin(admin.ModelAdmin):
,) ,)
readonly_fields = ('nome', 'logradouro', 'bairro', 'municipio', 'cep') readonly_fields = ('nome', 'logradouro', 'bairro', 'municipio', 'cep')
inlines = (ContatosInline,) inlines = (ContatosInline,)
list_filter = ('tipo', 'servico__tipo_servico', 'municipio__uf__nome', ) list_filter = ('tipo', 'servico__tipo_servico', 'municipio__uf__nome',
'servico__casa_legislativa__convenio__projeto')
search_fields = ('search_text','cnpj', 'bairro', 'logradouro', search_fields = ('search_text','cnpj', 'bairro', 'logradouro',
'cep', 'municipio__nome', 'municipio__uf__nome', 'cep', 'municipio__nome', 'municipio__uf__nome',
'municipio__codigo_ibge', 'pagina_web', 'observacoes') 'municipio__codigo_ibge', 'pagina_web', 'observacoes')

Loading…
Cancel
Save