Browse Source

Melhora na interface do app servidores

pull/66/head
Sesostris Vieira 4 years ago
parent
commit
c2be17e26c
  1. 24
      sigi/apps/servidores/admin.py
  2. 18
      sigi/apps/servidores/migrations/0005_auto_20210423_0904.py
  3. 2
      sigi/apps/servidores/models.py

24
sigi/apps/servidores/admin.py

@ -13,11 +13,33 @@ class ServidorFilter(AlphabeticFilter):
title = _(u'Nome do Servidor')
parameter_name = 'servidor__nome_completo'
class ServicoFilter(admin.SimpleListFilter):
title = _(u"Subordinados à")
parameter_name = 'subordinado__id__exact'
def lookups(self, request, model_admin):
return ([('None', _(u"Nenhum"))] +
[(s.id, s.nome) for s in Servico.objects.exclude(servico=None)])
def queryset(self, request, queryset):
if self.value():
if self.value() == "None":
queryset = queryset.filter(subordinado=None)
else:
queryset = queryset.filter(subordinado__id=self.value())
return queryset
class ServicoInline(admin.TabularInline):
model = Servico
fields = ['nome', 'sigla', 'responsavel',]
@admin.register(Servico)
class ServicoAdmin(admin.ModelAdmin):
list_display = ['sigla', 'nome', 'subordinado', 'responsavel']
list_filter = ['subordinado',]
list_filter = [ServicoFilter,]
search_fields = ['nome', 'sigla',]
inlines = [ServicoInline,]
@admin.register(Servidor)
class ServidorAdmin(BaseModelAdmin):

18
sigi/apps/servidores/migrations/0005_auto_20210423_0904.py

@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('servidores', '0004_auto_20210422_1907'),
]
operations = [
migrations.AlterModelOptions(
name='servico',
options={'ordering': ('-subordinado__sigla', 'nome'), 'verbose_name': 'servi\xe7o', 'verbose_name_plural': 'servi\xe7os'},
),
]

2
sigi/apps/servidores/models.py

@ -24,7 +24,7 @@ class Servico(models.Model):
)
class Meta:
ordering = ('nome',)
ordering = ('-subordinado__sigla', 'nome',)
verbose_name = _(u'serviço')
verbose_name_plural = _(u'serviços')

Loading…
Cancel
Save