Browse Source

Resolve regressão introduzida no commit 7ca4ae1

pull/163/head 3.0.36
Sesostris Vieira 2 years ago
parent
commit
a7f02d2841
  1. 5
      sigi/apps/casas/admin.py
  2. 8
      sigi/apps/convenios/admin.py
  3. 7
      sigi/apps/utils/__init__.py

5
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.models import Servico
from sigi.apps.servicos.filters import ServicoAtivoFilter from sigi.apps.servicos.filters import ServicoAtivoFilter
from sigi.apps.servidores.models import Servidor 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.filters import EmptyFilter
from sigi.apps.utils.mixins import ( from sigi.apps.utils.mixins import (
ReturnMixin, ReturnMixin,
@ -436,7 +436,8 @@ class OrgaoAdmin(CartExportReportMixin, admin.ModelAdmin):
] ]
def get_queryset(self, request): 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") return queryset.prefetch_related("gerentes_interlegis", "convenio_set")
def save_related(self, request, form, formsets, change): def save_related(self, request, form, formsets, change):

8
sigi/apps/convenios/admin.py

@ -17,7 +17,7 @@ from sigi.apps.convenios.models import (
Tramitacao, Tramitacao,
Gescon, 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.servidores.models import Servidor
from sigi.apps.casas.admin import ConveniosInline, GerentesInterlegisFilter from sigi.apps.casas.admin import ConveniosInline, GerentesInterlegisFilter
from sigi.apps.utils.mixins import ( from sigi.apps.utils.mixins import (
@ -222,8 +222,6 @@ class ConvenioAdmin(ReturnMixin, CartExportReportMixin, admin.ModelAdmin):
"report_convenios", "report_convenios",
] ]
get_queryset = queryset_ascii
def get_uf(self, obj): def get_uf(self, obj):
return obj.casa_legislativa.municipio.uf.sigla return obj.casa_legislativa.municipio.uf.sigla
@ -291,6 +289,10 @@ class ConvenioAdmin(ReturnMixin, CartExportReportMixin, admin.ModelAdmin):
del actions["delete_selected"] del actions["delete_selected"]
return actions return actions
def get_queryset(self, request):
asciify_q_param(request)
return super().get_queryset(request)
@admin.register(EquipamentoPrevisto) @admin.register(EquipamentoPrevisto)
class EquipamentoPrevistoAdmin(admin.ModelAdmin): class EquipamentoPrevistoAdmin(admin.ModelAdmin):

7
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: if "q" in request.GET:
request.GET._mutable = True request.GET._mutable = True
request.GET["q"] = to_ascii(request.GET["q"]) 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) return django_admin.ModelAdmin.get_queryset(self, request)

Loading…
Cancel
Save