From 4d3823def71728a8e09d53f06fd70acc85a5f9b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ses=C3=B3stris=20Vieira?= Date: Wed, 20 Mar 2024 10:21:43 -0300 Subject: [PATCH] =?UTF-8?q?Ajustes=20na=20integra=C3=A7=C3=A3o=20SIGI=20x?= =?UTF-8?q?=20Reserva=20de=20salas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sigi/apps/espacos/jobs/hourly/sincroniza_reservas.py | 7 ++++--- .../migrations/0008_carga_inicial_reserva_salas.py | 11 ++++++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/sigi/apps/espacos/jobs/hourly/sincroniza_reservas.py b/sigi/apps/espacos/jobs/hourly/sincroniza_reservas.py index 52a3847..1f56d65 100644 --- a/sigi/apps/espacos/jobs/hourly/sincroniza_reservas.py +++ b/sigi/apps/espacos/jobs/hourly/sincroniza_reservas.py @@ -290,7 +290,8 @@ class Job(JobReportMixin, HourlyJob): ) if conflitos: # Verificar se existe um conflitante com as mesmas - # datas/horas e coordenador. + # datas/horas e que tenha sido cadastrado diretamente + # no SIGI (id_reserva = None) reserva_sigi = Reserva.objects.filter( espaco=espaco, id_reserva=None, @@ -298,7 +299,6 @@ class Job(JobReportMixin, HourlyJob): data_termino=data_termino, hora_inicio=hora_inicio, hora_termino=hora_termino, - contato=reserva["coordenador"], ).first() if reserva_sigi: # Se existe, então é a mesma, bastando vincular @@ -516,13 +516,14 @@ class Job(JobReportMixin, HourlyJob): hora_inicio, hora_termino, ): + data_pedido = min(timezone.localdate(), data_inicio) reserva_sigi = Reserva( status=status, espaco=espaco, proposito=reserva["evento"], virtual=False, total_participantes=reserva["quantidadeAlunos"], - data_pedido=timezone.localdate(), + data_pedido=data_pedido, data_inicio=data_inicio, data_termino=data_termino, hora_inicio=hora_inicio, diff --git a/sigi/apps/espacos/migrations/0008_carga_inicial_reserva_salas.py b/sigi/apps/espacos/migrations/0008_carga_inicial_reserva_salas.py index e254a51..3378ddb 100644 --- a/sigi/apps/espacos/migrations/0008_carga_inicial_reserva_salas.py +++ b/sigi/apps/espacos/migrations/0008_carga_inicial_reserva_salas.py @@ -2,6 +2,7 @@ from datetime import datetime from django.db import migrations from django.db import migrations +from django.conf import settings from sigi.apps.espacos.jobs.hourly.sincroniza_reservas import Job @@ -15,10 +16,18 @@ def forward(apps, schema_editor): espaco.id_sala = id_sala espaco.save() + if ( + settings.RESERVA_SALA_BASE_URL is None + or settings.RESERVA_SALA_API_USER is None + or settings.RESERVA_SALA_API_PASSWORD is None + ): + # Acesso ao sistema não configurado. Não fazer nada + return + job = Job() job.carrega_salas() job.carrega_recursos() - job.carrega_reservas(ontem="2023-04-01") + job.carrega_reservas(ontem="2023-12-31") job.report(start, datetime.now())