Browse Source

HOT-FIX: otimiza query de matérias anexadas em lote (#2602)

pull/2601/head
Victor Fabre 6 years ago
committed by Edward Ribeiro
parent
commit
6a14fc6531
  1. 7
      sapl/materia/views.py

7
sapl/materia/views.py

@ -2042,11 +2042,12 @@ class MateriaAnexadaEmLoteView(PermissionRequiredMixin, FilterView):
data_desanexacao = datetime.strptime(
request.POST['data_desanexacao'], "%d/%m/%Y").date()
for materia_id in marcadas:
principal = MateriaLegislativa.objects.get(pk = kwargs['pk'])
for materia in MateriaLegislativa.objects.filter(id__in = marcadas):
anexada = Anexada()
anexada.materia_principal = MateriaLegislativa.objects.get(pk = kwargs['pk'])
anexada.materia_anexada = MateriaLegislativa.objects.get(pk = materia_id)
anexada.materia_principal = principal
anexada.materia_anexada = materia
anexada.data_anexacao = data_anexacao
anexada.data_desanexacao = data_desanexacao
anexada.save()

Loading…
Cancel
Save