From 7fa37d9d0d1d9191eb30e40213bee75bf73d7492 Mon Sep 17 00:00:00 2001 From: Lude Ribeiro Date: Fri, 15 Oct 2021 10:06:24 -0300 Subject: [PATCH 1/2] Acionando filtro de exclusao de convenios --- sigi/apps/casas/admin.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/sigi/apps/casas/admin.py b/sigi/apps/casas/admin.py index 2fe3928..48615f0 100644 --- a/sigi/apps/casas/admin.py +++ b/sigi/apps/casas/admin.py @@ -291,7 +291,7 @@ class ConvenioFilter(admin.SimpleListFilter): def lookups(self, request, model_admin): return ( ('SC', _(u"Sem nenhum convênio")), - ('CC', _(u"Com algum convênio")) + ('CC', _(u"Com algum convênio")), ) + tuple([(p.pk, p.sigla) for p in Projeto.objects.all()]) def queryset(self, request, queryset): @@ -305,6 +305,16 @@ class ConvenioFilter(admin.SimpleListFilter): return queryset.distinct('municipio__uf__nome', 'nome') +class ExcluirConvenioFilter(admin.SimpleListFilter): + title=_(u"Excluir convênio da pesquisa") + parameter_name = 'convenio_excluir' + + def lookups(self, request, model_admin): + return tuple([(p.pk, p.sigla) for p in Projeto.objects.all()]) + + def queryset(self, request, queryset): + queryset = queryset.exclude(convenio__projeto_id=self.value()) + return queryset.distinct('municipio__uf__nome', 'nome') class ServicoFilter(admin.SimpleListFilter): title = _(u"Serviço") @@ -350,7 +360,7 @@ class OrgaoAdmin(ImageCroppingMixin, BaseModelAdmin): 'get_servicos') list_display_links = ('sigla', 'nome',) list_filter = ('tipo', ('gerentes_interlegis', GerentesInterlegisFilter), - 'municipio__uf__nome', ConvenioFilter, ServicoFilter, + 'municipio__uf__nome', ConvenioFilter, ExcluirConvenioFilter, ServicoFilter, 'inclusao_digital',) ordering = ('municipio__uf__nome', 'nome') queryset = queryset_ascii From d99e98c1b24fe0974ac73009604e5d0f51ec3472 Mon Sep 17 00:00:00 2001 From: Lude Ribeiro Date: Fri, 15 Oct 2021 12:00:55 -0300 Subject: [PATCH 2/2] Fix #75 --- sigi/apps/casas/admin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sigi/apps/casas/admin.py b/sigi/apps/casas/admin.py index 48615f0..19b67f8 100644 --- a/sigi/apps/casas/admin.py +++ b/sigi/apps/casas/admin.py @@ -307,7 +307,7 @@ class ConvenioFilter(admin.SimpleListFilter): class ExcluirConvenioFilter(admin.SimpleListFilter): title=_(u"Excluir convênio da pesquisa") - parameter_name = 'convenio_excluir' + parameter_name = 'excluir_convenio' def lookups(self, request, model_admin): return tuple([(p.pk, p.sigla) for p in Projeto.objects.all()])