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.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):

8
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):

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:
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)

Loading…
Cancel
Save