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; sendfile off;
#tcp_nopush on; #tcp_nopush on;
keepalive_timeout 65; keepalive_timeout 300;
proxy_connect_timeout 75s;
proxy_read_timeout 300s;
gzip on; gzip on;
gzip_disable "MSIE [1-6]\\.(?!.*SV1)"; gzip_disable "MSIE [1-6]\\.(?!.*SV1)";

9
docker/docker-compose.yml

@ -32,15 +32,16 @@ services:
networks: networks:
- sapl-net - sapl-net
sapl: sapl:
image: interlegis/sapl:3.1.162-RC11 #image: interlegis/sapl:3.1.162-RC11
# build: build:
# context: ../ context: ../
# dockerfile: ./docker/Dockerfile dockerfile: ./docker/Dockerfile
container_name: sapl container_name: sapl
labels: labels:
NAME: "sapl" NAME: "sapl"
restart: always restart: always
environment: environment:
LOGGING_CONSOLE_VERBOSE: 'True'
ADMIN_PASSWORD: interlegis ADMIN_PASSWORD: interlegis
ADMIN_EMAIL: email@dominio.net ADMIN_EMAIL: email@dominio.net
DEBUG: 'False' 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 (*) GROUP=`whoami` # the group to run as (*)
NUM_WORKERS=3 # how many worker processes should Gunicorn spawn (*) NUM_WORKERS=3 # how many worker processes should Gunicorn spawn (*)
# NUM_WORKERS = 2 * CPUS + 1 # NUM_WORKERS = 2 * CPUS + 1
TIMEOUT=60 TIMEOUT=300
MAX_REQUESTS=100 # number of requests before restarting worker MAX_REQUESTS=100 # number of requests before restarting worker
DJANGO_SETTINGS_MODULE=sapl.settings # which settings file should Django use (*) DJANGO_SETTINGS_MODULE=sapl.settings # which settings file should Django use (*)
DJANGO_WSGI_MODULE=sapl.wsgi # WSGI module name (*) 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['tipo'].label = 'Tipo de Matéria'
self.filters['data_apresentacao'].label = 'Data (Inicial - Final)' 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)]) row1 = to_row([('tipo', 12)])
row2 = to_row([('data_apresentacao', 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 proposicao.texto_original:
if (not proposicao.data_recebimento and if (not proposicao.data_recebimento and
not proposicao.autor.operadores.filter( not proposicao.autor.operadores.filter(
id=request.user.id id=request.user.id
).exists() ).exists()
): ):
logger.error("user=" + username + ". Usuário ({}) não tem permissão para acessar o texto original." logger.error("user=" + username + ". Usuário ({}) não tem permissão para acessar o texto original."
.format(request.user.id)) .format(request.user.id))
messages.error(request, _( messages.error(request, _(
@ -2385,39 +2385,42 @@ class MateriaAnexadaEmLoteView(PermissionRequiredMixin, FilterView):
return context return context
qr = self.request.GET.copy() qr = self.request.GET.copy()
context['object_list'] = context['object_list'].order_by( if not len(qr):
'numero', '-ano') context['object_list'] = []
principal = MateriaLegislativa.objects.get(pk=self.kwargs['pk']) else:
not_list = [self.kwargs['pk']] + \ context['object_list'] = context['object_list'].order_by(
[m for m in principal.materia_principal_set.all( 'numero', '-ano')
).values_list('materia_anexada_id', flat=True)] principal = MateriaLegislativa.objects.get(pk=self.kwargs['pk'])
context['object_list'] = context['object_list'].exclude( not_list = [self.kwargs['pk']] + \
pk__in=not_list) [m for m in principal.materia_principal_set.all(
).values_list('materia_anexada_id', flat=True)]
context['temp_object_list'] = context['object_list'] context['object_list'] = context['object_list'].exclude(
context['object_list'] = [] pk__in=not_list)
for obj in context['temp_object_list']:
materia_anexada = obj context['temp_object_list'] = context['object_list']
ciclico = False context['object_list'] = []
anexadas_anexada = Anexada.objects.filter( for obj in context['temp_object_list']:
materia_principal=materia_anexada materia_anexada = obj
) ciclico = False
anexadas_anexada = Anexada.objects.filter(
materia_principal=materia_anexada
)
while anexadas_anexada and not ciclico: while anexadas_anexada and not ciclico:
anexadas = [] anexadas = []
for anexa in anexadas_anexada: for anexa in anexadas_anexada:
if principal == anexa.materia_anexada: if principal == anexa.materia_anexada:
ciclico = True ciclico = True
else: else:
for a in Anexada.objects.filter(materia_principal=anexa.materia_anexada): for a in Anexada.objects.filter(materia_principal=anexa.materia_anexada):
anexadas.append(a) anexadas.append(a)
anexadas_anexada = anexadas anexadas_anexada = anexadas
if not ciclico: if not ciclico:
context['object_list'].append(obj) context['object_list'].append(obj)
context['numero_res'] = len(context['object_list']) context['numero_res'] = len(context['object_list'])

Loading…
Cancel
Save