diff --git a/sigi/apps/convenios/admin.py b/sigi/apps/convenios/admin.py index 8d01d74..86775ab 100644 --- a/sigi/apps/convenios/admin.py +++ b/sigi/apps/convenios/admin.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- from django.contrib import admin from sigi.apps.convenios.models import Convenio, EquipamentoPrevisto, Anexo +from sigi.apps.servicos.models import Servico class AnexosInline(admin.TabularInline): model = Anexo @@ -10,6 +11,10 @@ class EquipamentoPrevistoInline(admin.TabularInline): model = EquipamentoPrevisto extra = 2 +class ServicosInline(admin.StackedInline): + model = Servico + extra = 1 + class AnexoAdmin(admin.ModelAdmin): date_hierarchy = 'data_pub' exclude = ['data_pub',] @@ -27,11 +32,11 @@ class ConvenioAdmin(admin.ModelAdmin): {'fields': ('data_adesao', 'data_retorno_assinatura', 'data_termo_aceite', 'data_pub_diario')} ), - ('Equipamentos & Serviços', - {'fields': ('equipamentos_recebidos', 'servicos')} + ('Equipamentos', + {'fields': ('equipamentos_recebidos',)} ) ) - inlines = (AnexosInline, EquipamentoPrevistoInline) + inlines = (AnexosInline, EquipamentoPrevistoInline, ServicosInline) list_display = ('num_convenio', 'casa_legislativa', 'num_processo_sf', 'data_adesao') list_filter = ('equipamentos_recebidos',) diff --git a/sigi/apps/convenios/models.py b/sigi/apps/convenios/models.py index 060a1e7..6eeb9ba 100644 --- a/sigi/apps/convenios/models.py +++ b/sigi/apps/convenios/models.py @@ -39,12 +39,6 @@ class Convenio(models.Model): max_length=1, choices=RECEBIDOS_CHOICES, ) - servicos = models.ManyToManyField( - 'servicos.Servico', - verbose_name='serviços prestados', - null=True, - blank=True - ) class Meta: get_latest_by = 'num_convenio' diff --git a/sigi/apps/servicos/admin.py b/sigi/apps/servicos/admin.py index a3592ca..427099d 100644 --- a/sigi/apps/servicos/admin.py +++ b/sigi/apps/servicos/admin.py @@ -13,8 +13,8 @@ class ContatosInline(generic.GenericTabularInline): class ServicoAdmin(admin.ModelAdmin): date_hierarchy = 'data_inicio' inlines = (ContatosInline,) - list_display = ('id', 'titulo', 'tipo', 'situacao', 'avaliacao') - list_filter = ('tipo','situacao', 'avaliacao',) - search_fields = ('titulo', 'tipo', 'descricao',) + list_display = ('id', 'titulo', 'tipo', 'convenio', 'situacao') + list_filter = ('tipo','situacao', 'avaliacao') + search_fields = ('titulo', 'tipo', 'descricao') admin.site.register(Servico, ServicoAdmin) diff --git a/sigi/apps/servicos/models.py b/sigi/apps/servicos/models.py index 8b01016..1f0a266 100644 --- a/sigi/apps/servicos/models.py +++ b/sigi/apps/servicos/models.py @@ -19,6 +19,7 @@ class Servico(models.Model): titulo = models.CharField('título', max_length=60) tipo = models.CharField(max_length=30) descricao = models.TextField(u'descrição') + convenio = models.ForeignKey('convenios.Convenio', verbose_name='Convênio') colaboradores = generic.GenericRelation('contatos.Contato') data_inicio = models.DateField( u'início',