Browse Source

Adiciona filtro de solicitações por microrregião. Gertiq #169978

pull/169/head
Sesóstris Vieira 1 year ago
parent
commit
3cdfc3da9f
  1. 16
      sigi/apps/eventos/admin.py

16
sigi/apps/eventos/admin.py

@ -1,6 +1,7 @@
import datetime import datetime
import pandas as pd import pandas as pd
import time import time
from admin_auto_filters.filters import AutocompleteFilter
from moodle import Moodle from moodle import Moodle
from typing import Any from typing import Any
from django.db import models from django.db import models
@ -37,7 +38,7 @@ from tinymce.models import HTMLField
from tinymce.widgets import AdminTinyMCE from tinymce.widgets import AdminTinyMCE
from weasyprint import HTML from weasyprint import HTML
from sigi.apps.convenios.models import Convenio from sigi.apps.convenios.models import Convenio
from sigi.apps.contatos.models import UnidadeFederativa from sigi.apps.contatos.models import UnidadeFederativa, Municipio
from sigi.apps.eventos.models import ( from sigi.apps.eventos.models import (
Checklist, Checklist,
Cronograma, Cronograma,
@ -105,6 +106,13 @@ class NumeroParticipantesFilter(admin.SimpleListFilter):
).filter(diferenca__gte=10) ).filter(diferenca__gte=10)
class MicrorregiaoFilter(AutocompleteFilter):
title = _("Microrregião")
parameter_name = "casa__municipio__microrregiao__codigo_ibge__exact"
field_name = "microrregiao"
rel_model = Municipio
class SolicitacaoResource(LabeledResourse): class SolicitacaoResource(LabeledResourse):
act_vigente = Field(column_name="ACT vigente") act_vigente = Field(column_name="ACT vigente")
data_termino_act = Field(column_name="término vigência ACT") data_termino_act = Field(column_name="término vigência ACT")
@ -414,6 +422,7 @@ class SolicitacaoAdmin(AsciifyQParameter, CartExportMixin, admin.ModelAdmin):
"itemsolicitado__tipo_evento", "itemsolicitado__tipo_evento",
"status", "status",
ActVigenteFilter, ActVigenteFilter,
MicrorregiaoFilter,
) )
list_select_related = ["casa", "casa__municipio", "casa__municipio__uf"] list_select_related = ["casa", "casa__municipio", "casa__municipio__uf"]
search_fields = ( search_fields = (
@ -469,6 +478,11 @@ class SolicitacaoAdmin(AsciifyQParameter, CartExportMixin, admin.ModelAdmin):
inlines = (ItemSolicitadoInline, AnexoSolicitacaoInline) inlines = (ItemSolicitadoInline, AnexoSolicitacaoInline)
autocomplete_fields = ("casa",) autocomplete_fields = ("casa",)
def lookup_allowed(self, lookup, value):
return super().lookup_allowed(lookup, value) or (
lookup == MicrorregiaoFilter.parameter_name
)
def get_queryset(self, request): def get_queryset(self, request):
acts = Convenio.objects.filter( acts = Convenio.objects.filter(
casa_legislativa=OuterRef("casa"), casa_legislativa=OuterRef("casa"),

Loading…
Cancel
Save