From a7f02d2841047d53243a428ce8e0cce90a993c6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ses=C3=B3stris=20Vieira?= Date: Fri, 31 Mar 2023 17:07:20 -0300 Subject: [PATCH] =?UTF-8?q?Resolve=20regress=C3=A3o=20introduzida=20no=20c?= =?UTF-8?q?ommit=207ca4ae1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sigi/apps/casas/admin.py | 5 +++-- sigi/apps/convenios/admin.py | 8 +++++--- sigi/apps/utils/__init__.py | 7 ++++++- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/sigi/apps/casas/admin.py b/sigi/apps/casas/admin.py index e6b4f10..2bc03cd 100644 --- a/sigi/apps/casas/admin.py +++ b/sigi/apps/casas/admin.py @@ -22,7 +22,7 @@ from sigi.apps.parlamentares.models import Parlamentar from sigi.apps.servicos.models import Servico from sigi.apps.servicos.filters import ServicoAtivoFilter from sigi.apps.servidores.models import Servidor -from sigi.apps.utils import queryset_ascii +from sigi.apps.utils import asciify_q_param from sigi.apps.utils.filters import EmptyFilter from sigi.apps.utils.mixins import ( ReturnMixin, @@ -436,7 +436,8 @@ class OrgaoAdmin(CartExportReportMixin, admin.ModelAdmin): ] def get_queryset(self, request): - queryset = queryset_ascii(self, request) + asciify_q_param(request) + queryset = super().get_queryset(request) return queryset.prefetch_related("gerentes_interlegis", "convenio_set") def save_related(self, request, form, formsets, change): diff --git a/sigi/apps/convenios/admin.py b/sigi/apps/convenios/admin.py index 8b0848e..74160fb 100644 --- a/sigi/apps/convenios/admin.py +++ b/sigi/apps/convenios/admin.py @@ -17,7 +17,7 @@ from sigi.apps.convenios.models import ( Tramitacao, Gescon, ) -from sigi.apps.utils import queryset_ascii +from sigi.apps.utils import queryset_ascii, asciify_q_param from sigi.apps.servidores.models import Servidor from sigi.apps.casas.admin import ConveniosInline, GerentesInterlegisFilter from sigi.apps.utils.mixins import ( @@ -222,8 +222,6 @@ class ConvenioAdmin(ReturnMixin, CartExportReportMixin, admin.ModelAdmin): "report_convenios", ] - get_queryset = queryset_ascii - def get_uf(self, obj): return obj.casa_legislativa.municipio.uf.sigla @@ -291,6 +289,10 @@ class ConvenioAdmin(ReturnMixin, CartExportReportMixin, admin.ModelAdmin): del actions["delete_selected"] return actions + def get_queryset(self, request): + asciify_q_param(request) + return super().get_queryset(request) + @admin.register(EquipamentoPrevisto) class EquipamentoPrevistoAdmin(admin.ModelAdmin): diff --git a/sigi/apps/utils/__init__.py b/sigi/apps/utils/__init__.py index 2fa9cab..a7acb48 100644 --- a/sigi/apps/utils/__init__.py +++ b/sigi/apps/utils/__init__.py @@ -39,10 +39,15 @@ def to_ascii(txt, codif="utf-8"): ) -def queryset_ascii(self, request): +def asciify_q_param(request): if "q" in request.GET: request.GET._mutable = True request.GET["q"] = to_ascii(request.GET["q"]) + request.GET._mutable = False + + +def queryset_ascii(self, request): + asciify_q_param(request) return django_admin.ModelAdmin.get_queryset(self, request)