diff --git a/sigi/apps/casas/admin.py b/sigi/apps/casas/admin.py index 5e8043b..b7212bf 100644 --- a/sigi/apps/casas/admin.py +++ b/sigi/apps/casas/admin.py @@ -517,9 +517,7 @@ class OrgaoAdmin(AsciifyQParameter, ExportActionMixin, admin.ModelAdmin): queryset = super().get_queryset(request) return queryset.prefetch_related("gerentes_interlegis", "convenio_set") - def changeform_view( - self, request, object_id, form_url, extra_context=None - ): + def changeform_view(self, request, object_id, form_url, extra_context=None): extra_context = extra_context or {} extra_context["show_save_and_add_another"] = False return super().changeform_view( @@ -591,10 +589,8 @@ class OrgaoAdmin(AsciifyQParameter, ExportActionMixin, admin.ModelAdmin): + "" ) - def lookup_allowed(self, lookup, value): - return super(OrgaoAdmin, self).lookup_allowed( - lookup, value - ) or lookup in [ + def lookup_allowed(self, lookup, value, request): + return super().lookup_allowed(lookup, value, request) or lookup in [ "tipo__legislativo__exact", "tipo__sigla__exact", "tipo__sigla__in", diff --git a/sigi/apps/diagnosticos/admin.py b/sigi/apps/diagnosticos/admin.py index f273682..763c3c6 100644 --- a/sigi/apps/diagnosticos/admin.py +++ b/sigi/apps/diagnosticos/admin.py @@ -127,9 +127,7 @@ class DiagnosticoAdmin(BaseEntityAdmin): perguntas_by_title = [ (p.title, p.name) for p in categoria.perguntas.all() ] - perguntas = [ - pergunta[1] for pergunta in sorted(perguntas_by_title) - ] + perguntas = [pergunta[1] for pergunta in sorted(perguntas_by_title)] eav_fieldsets += ( ( @@ -148,10 +146,10 @@ class DiagnosticoAdmin(BaseEntityAdmin): get_uf.short_description = _("UF") get_uf.admin_order_field = "casa_legislativa__municipio__uf__nome" - def lookup_allowed(self, lookup, value): - return super(DiagnosticoAdmin, self).lookup_allowed( - lookup, value - ) or lookup in ["casa_legislativa__municipio__uf__codigo_ibge__exact"] + def lookup_allowed(self, lookup, value, request): + return super().lookup_allowed(lookup, value, request) or lookup in [ + "casa_legislativa__municipio__uf__codigo_ibge__exact" + ] def changelist_view(self, request, extra_context=None): import re diff --git a/sigi/apps/eventos/admin.py b/sigi/apps/eventos/admin.py index eed0e42..3fe8be1 100644 --- a/sigi/apps/eventos/admin.py +++ b/sigi/apps/eventos/admin.py @@ -523,8 +523,8 @@ class SolicitacaoAdmin(AsciifyQParameter, ExportActionMixin, admin.ModelAdmin): inlines = (ItemSolicitadoInline, AnexoSolicitacaoInline) autocomplete_fields = ("casa",) - def lookup_allowed(self, lookup, value): - return super().lookup_allowed(lookup, value) or ( + def lookup_allowed(self, lookup, value, request): + return super().lookup_allowed(lookup, value, request) or ( lookup == MicrorregiaoFilter.parameter_name ) @@ -655,9 +655,7 @@ class SolicitacaoAdmin(AsciifyQParameter, ExportActionMixin, admin.ModelAdmin): data_recebido_coperi=item.solicitacao.data_recebido_coperi, data_inicio=item.inicio_desejado, data_termino=item.inicio_desejado - + datetime.timedelta( - days=item.tipo_evento.duracao - ), + + datetime.timedelta(days=item.tipo_evento.duracao), casa_anfitria=item.solicitacao.casa, observacao=_( f"Autorizado por {servidor} com a justificativa '{item.justificativa}" @@ -761,9 +759,7 @@ class SolicitacaoAdmin(AsciifyQParameter, ExportActionMixin, admin.ModelAdmin): + "" ) - @admin.display( - description=_("Município"), ordering="casa__municipio__nome" - ) + @admin.display(description=_("Município"), ordering="casa__municipio__nome") def get_municipio(self, obj): return obj.casa.municipio.nome @@ -818,9 +814,7 @@ class SolicitacaoAdmin(AsciifyQParameter, ExportActionMixin, admin.ModelAdmin): def get_populacao(self, obj): return obj.casa.municipio.populacao - @admin.display( - description=_("Oficinas atendidas/confirmadas no município") - ) + @admin.display(description=_("Oficinas atendidas/confirmadas no município")) def get_oficinas_municipio(self, obj): ano_corrente = timezone.localdate().year counters = Evento.objects.filter( @@ -1076,9 +1070,7 @@ class EventoAdmin(AsciifyQParameter, ExportActionMixin, admin.ModelAdmin): else: return None - @admin.display( - description=_("UF"), ordering="casa_anfitria__municipio__uf" - ) + @admin.display(description=_("UF"), ordering="casa_anfitria__municipio__uf") def get_uf(self, obj): if obj.casa_anfitria: return obj.casa_anfitria.municipio.uf.nome @@ -1152,10 +1144,8 @@ class EventoAdmin(AsciifyQParameter, ExportActionMixin, admin.ModelAdmin): request, context, add, change, form_url, obj ) - def lookup_allowed(self, lookup, value): - return super(EventoAdmin, self).lookup_allowed( - lookup, value - ) or lookup in [ + def lookup_allowed(self, lookup, value, request): + return super().lookup_allowed(lookup, value, request) or lookup in [ "tipo_evento__nome__exact", "tipo_evento__nome__contains", ] @@ -1348,8 +1338,7 @@ class EventoAdmin(AsciifyQParameter, ExportActionMixin, admin.ModelAdmin): ) termino = max( cronograma[-1].data_prevista_termino, - cronograma[-1].data_termino - or cronograma[-1].data_prevista_termino, + cronograma[-1].data_termino or cronograma[-1].data_prevista_termino, ) datas = [ inicio + datetime.timedelta(days=x) diff --git a/sigi/apps/metas/admin.py b/sigi/apps/metas/admin.py index 9536dd3..80989a0 100644 --- a/sigi/apps/metas/admin.py +++ b/sigi/apps/metas/admin.py @@ -58,10 +58,10 @@ class PlanoDiretorAdmin(BaseModelAdmin): get_uf.short_description = _("UF") get_uf.admin_order_field = "casa_legislativa__municipio__uf__nome" - def lookup_allowed(self, lookup, value): - return super(PlanoDiretorAdmin, self).lookup_allowed( - lookup, value - ) or lookup in ["casa_legislativa__municipio__uf__codigo_ibge__exact"] + def lookup_allowed(self, lookup, value, request): + return super().lookup_allowed(lookup, value, request) or lookup in [ + "casa_legislativa__municipio__uf__codigo_ibge__exact" + ] def changelist_view(self, request, extra_context=None): import re diff --git a/sigi/apps/servicos/admin.py b/sigi/apps/servicos/admin.py index b65848a..5659f03 100644 --- a/sigi/apps/servicos/admin.py +++ b/sigi/apps/servicos/admin.py @@ -180,10 +180,8 @@ class ServicoAdmin(ReturnMixin, ExportActionMixin, admin.ModelAdmin): "Atualizar a data do último uso do(s) serviço(s)" ) - def lookup_allowed(self, lookup, value): - return super(ServicoAdmin, self).lookup_allowed( - lookup, value - ) or lookup in [ + def lookup_allowed(self, lookup, value, request): + return super().lookup_allowed(lookup, value, request) or lookup in [ "casa_legislativa__municipio__uf__codigo_ibge__exact", ] diff --git a/sigi/apps/servidores/admin.py b/sigi/apps/servidores/admin.py index 1b0fee6..17ccf39 100644 --- a/sigi/apps/servidores/admin.py +++ b/sigi/apps/servidores/admin.py @@ -133,10 +133,10 @@ class ServidorAdmin(admin.ModelAdmin): ), ) - def lookup_allowed(self, lookup, value): - return super(ServidorAdmin, self).lookup_allowed( - lookup, value - ) or lookup in ["user__is_active__exact"] + def lookup_allowed(self, lookup, value, request): + return super().lookup_allowed(lookup, value, request) or lookup in [ + "user__is_active__exact" + ] def is_active(self, servidor): if servidor.user: