Browse Source

Otimização de consultas em views (#3474)

* Otimização de consultas em views

* Update sapl/protocoloadm/views.py

Co-authored-by: Edward <9326037+edwardoliveira@users.noreply.github.com>
pull/3486/head
Alvaro Gouvea 3 years ago
committed by Edward Oliveira
parent
commit
fd86b7b79f
  1. 4
      sapl/comissoes/views.py
  2. 5
      sapl/materia/views.py
  3. 8
      sapl/protocoloadm/views.py

4
sapl/comissoes/views.py

@ -351,10 +351,12 @@ class AdicionaPautaView(PermissionRequiredMixin, FilterView):
context['root_pk'] = context['object'].comissao.pk
qr = self.request.GET.copy()
materias_pauta = PautaReuniao.objects.filter(reuniao=context['object'])
nao_listar = [mp.materia.pk for mp in materias_pauta]
if not len(qr):
context['object_list'] = []
else:
context['object_list'] = context['object_list'].filter(
tramitacao__unidade_tramitacao_destino__comissao=context['root_pk']
).exclude(materia__pk__in=nao_listar).order_by(

5
sapl/materia/views.py

@ -2263,8 +2263,13 @@ class DocumentoAcessorioEmLoteView(PermissionRequiredMixin, FilterView):
qr = self.request.GET.copy()
context['tipos_docs'] = TipoDocumento.objects.all()
if not len(qr):
context['object_list'] = []
else:
context['object_list'] = context['object_list'].order_by(
'ano', 'numero')
context['filter_url'] = ('&' + qr.urlencode()) if len(qr) > 0 else ''
context['show_results'] = show_results_filter_set(qr)

8
sapl/protocoloadm/views.py

@ -1122,10 +1122,11 @@ class DocumentoAnexadoEmLoteView(PermissionRequiredMixin, FilterView):
return context
qr = self.request.GET.copy()
if not len(qr):
context['object_list'] = []
else:
context['temp_object_list'] = context['object_list'].order_by(
'numero', '-ano'
)
'numero', '-ano')
context['object_list'] = []
for obj in context['temp_object_list']:
if not obj.pk == int(context['root_pk']):
@ -1155,6 +1156,7 @@ class DocumentoAnexadoEmLoteView(PermissionRequiredMixin, FilterView):
if not ciclico:
context['object_list'].append(obj)
context['numero_res'] = len(context['object_list'])
context['filter_url'] = ('&' + qr.urlencode()) if len(qr) > 0 else ''

Loading…
Cancel
Save