Browse Source

HOT-FIX: Corrige constr de contexto na anex de mat

- Remove a analise de vínculos cíclicos na construção inicial
do form do filterset.
- O item anterior deve resolver o timeout causado na abertura da
anexação em lote, no entanto os timeouts do nginx e gunicorn foram
aumentados.
pull/3465/head
Leandro Roberto 3 years ago
parent
commit
1bbf473e6e
  1. 6
      docker/config/nginx/nginx.conf
  2. 9
      docker/docker-compose.yml
  3. 2
      docker/gunicorn_start.sh
  4. 3
      sapl/materia/forms.py
  5. 63
      sapl/materia/views.py

6
docker/config/nginx/nginx.conf

@ -23,7 +23,11 @@ http {
sendfile off;
#tcp_nopush on;
keepalive_timeout 65;
keepalive_timeout 300;
proxy_connect_timeout 75s;
proxy_read_timeout 300s;
gzip on;
gzip_disable "MSIE [1-6]\\.(?!.*SV1)";

9
docker/docker-compose.yml

@ -32,15 +32,16 @@ services:
networks:
- sapl-net
sapl:
image: interlegis/sapl:3.1.162-RC11
# build:
# context: ../
# dockerfile: ./docker/Dockerfile
#image: interlegis/sapl:3.1.162-RC11
build:
context: ../
dockerfile: ./docker/Dockerfile
container_name: sapl
labels:
NAME: "sapl"
restart: always
environment:
LOGGING_CONSOLE_VERBOSE: 'True'
ADMIN_PASSWORD: interlegis
ADMIN_EMAIL: email@dominio.net
DEBUG: 'False'

2
docker/gunicorn_start.sh

@ -25,7 +25,7 @@ USER=`whoami` # the user to run as (*)
GROUP=`whoami` # the group to run as (*)
NUM_WORKERS=3 # how many worker processes should Gunicorn spawn (*)
# NUM_WORKERS = 2 * CPUS + 1
TIMEOUT=60
TIMEOUT=300
MAX_REQUESTS=100 # number of requests before restarting worker
DJANGO_SETTINGS_MODULE=sapl.settings # which settings file should Django use (*)
DJANGO_WSGI_MODULE=sapl.wsgi # WSGI module name (*)

3
sapl/materia/forms.py

@ -1416,6 +1416,9 @@ class AnexadaEmLoteFilterSet(django_filters.FilterSet):
self.filters['tipo'].label = 'Tipo de Matéria'
self.filters['data_apresentacao'].label = 'Data (Inicial - Final)'
self.form.fields['tipo'].required = True
self.form.fields['data_apresentacao'].required = True
row1 = to_row([('tipo', 12)])
row2 = to_row([('data_apresentacao', 12)])

63
sapl/materia/views.py

@ -104,10 +104,10 @@ def proposicao_texto(request, pk):
if proposicao.texto_original:
if (not proposicao.data_recebimento and
not proposicao.autor.operadores.filter(
not proposicao.autor.operadores.filter(
id=request.user.id
).exists()
):
):
logger.error("user=" + username + ". Usuário ({}) não tem permissão para acessar o texto original."
.format(request.user.id))
messages.error(request, _(
@ -2385,39 +2385,42 @@ class MateriaAnexadaEmLoteView(PermissionRequiredMixin, FilterView):
return context
qr = self.request.GET.copy()
context['object_list'] = context['object_list'].order_by(
'numero', '-ano')
principal = MateriaLegislativa.objects.get(pk=self.kwargs['pk'])
not_list = [self.kwargs['pk']] + \
[m for m in principal.materia_principal_set.all(
).values_list('materia_anexada_id', flat=True)]
context['object_list'] = context['object_list'].exclude(
pk__in=not_list)
context['temp_object_list'] = context['object_list']
context['object_list'] = []
for obj in context['temp_object_list']:
materia_anexada = obj
ciclico = False
anexadas_anexada = Anexada.objects.filter(
materia_principal=materia_anexada
)
if not len(qr):
context['object_list'] = []
else:
context['object_list'] = context['object_list'].order_by(
'numero', '-ano')
principal = MateriaLegislativa.objects.get(pk=self.kwargs['pk'])
not_list = [self.kwargs['pk']] + \
[m for m in principal.materia_principal_set.all(
).values_list('materia_anexada_id', flat=True)]
context['object_list'] = context['object_list'].exclude(
pk__in=not_list)
context['temp_object_list'] = context['object_list']
context['object_list'] = []
for obj in context['temp_object_list']:
materia_anexada = obj
ciclico = False
anexadas_anexada = Anexada.objects.filter(
materia_principal=materia_anexada
)
while anexadas_anexada and not ciclico:
anexadas = []
while anexadas_anexada and not ciclico:
anexadas = []
for anexa in anexadas_anexada:
for anexa in anexadas_anexada:
if principal == anexa.materia_anexada:
ciclico = True
else:
for a in Anexada.objects.filter(materia_principal=anexa.materia_anexada):
anexadas.append(a)
if principal == anexa.materia_anexada:
ciclico = True
else:
for a in Anexada.objects.filter(materia_principal=anexa.materia_anexada):
anexadas.append(a)
anexadas_anexada = anexadas
anexadas_anexada = anexadas
if not ciclico:
context['object_list'].append(obj)
if not ciclico:
context['object_list'].append(obj)
context['numero_res'] = len(context['object_list'])

Loading…
Cancel
Save