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/3480/head
Alvaro Gouvea
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with
49 additions and
40 deletions
-
sapl/comissoes/views.py
-
sapl/materia/views.py
-
sapl/protocoloadm/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( |
|
|
|
|
|
@ -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) |
|
|
|
|
|
@ -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 '' |
|
|
|