From 952dfb03ff327e89afd68cdea348159cd3dedd58 Mon Sep 17 00:00:00 2001 From: Lemuel Marquez Date: Wed, 21 Jul 2021 10:46:35 -0500 Subject: [PATCH] validacion asistencia dia correcto --- .../monitor.js => GrupoHorario.js/horariosDIa.js} | 0 server/controller/GrupoHorario.js/monitor.js | 0 server/controller/PrimerSemestre/asistencia.js | 6 +++--- server/controller/TercerSemestre/csv.js | 4 ++-- server/controller/TercerSemestre/registrar.js | 4 ++-- server/routes/PrimerSemestre.js | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) rename server/controller/{TercerSemestre/monitor.js => GrupoHorario.js/horariosDIa.js} (100%) create mode 100644 server/controller/GrupoHorario.js/monitor.js diff --git a/server/controller/TercerSemestre/monitor.js b/server/controller/GrupoHorario.js/horariosDIa.js similarity index 100% rename from server/controller/TercerSemestre/monitor.js rename to server/controller/GrupoHorario.js/horariosDIa.js diff --git a/server/controller/GrupoHorario.js/monitor.js b/server/controller/GrupoHorario.js/monitor.js new file mode 100644 index 0000000..e69de29 diff --git a/server/controller/PrimerSemestre/asistencia.js b/server/controller/PrimerSemestre/asistencia.js index f167b56..b79b657 100644 --- a/server/controller/PrimerSemestre/asistencia.js +++ b/server/controller/PrimerSemestre/asistencia.js @@ -7,6 +7,7 @@ const PrimerSemestre = require(`${dbPath}/PrimerSemestre`); const asistencia = async (body) => { const idPrimerSemestre = validar.validarId(body.idPrimerSemestre); + const hoy = moment(); return PrimerSemestre.findOne({ where: { idPrimerSemestre }, @@ -16,9 +17,8 @@ const asistencia = async (body) => { if (!res) throw new Error('No existe este alumno.'); if (res.asistio) throw new Error('Ya fue registrada la asistencia de este alumno.'); - /* - Validar que sea el dia del recorrido - */ + if (hoy.dayOfYear() != moment(res.Horario.horario).dayOfYear()) + throw new Error('Este alumno no tiene una cita para el día de hoy.'); return PrimerSemestre.update( { asistio: true }, { where: { idPrimerSemestre } } diff --git a/server/controller/TercerSemestre/csv.js b/server/controller/TercerSemestre/csv.js index 9aac3ae..e7591d5 100644 --- a/server/controller/TercerSemestre/csv.js +++ b/server/controller/TercerSemestre/csv.js @@ -10,7 +10,7 @@ const GrupoHorario = require(`${dbPath}/GrupoHorario`); const Horario = require(`${dbPath}/Horario`); const TercerSemestre = require(`${dbPath}/TercerSemestre`); -const get = async (body) => { +const csv = async (body) => { const path = `server/uploads/tercer_semestre.csv`; const data = []; @@ -56,4 +56,4 @@ const get = async (body) => { .then((res) => path); }; -module.exports = get; +module.exports = csv; diff --git a/server/controller/TercerSemestre/registrar.js b/server/controller/TercerSemestre/registrar.js index 9835a28..5ca4241 100644 --- a/server/controller/TercerSemestre/registrar.js +++ b/server/controller/TercerSemestre/registrar.js @@ -9,7 +9,7 @@ const GrupoHorario = require(`${dbPath}/GrupoHorario`); const Horario = require(`${dbPath}/Horario`); const TercerSemestre = require(`${dbPath}/TercerSemestre`); -const get = async (body) => { +const registrar = async (body) => { const idTercerSemestre = validarId(body.idTercerSemestre); let alumno = {}; let mail = {}; @@ -54,4 +54,4 @@ const get = async (body) => { })); }; -module.exports = get; +module.exports = registrar; diff --git a/server/routes/PrimerSemestre.js b/server/routes/PrimerSemestre.js index 5255eed..5d12149 100644 --- a/server/routes/PrimerSemestre.js +++ b/server/routes/PrimerSemestre.js @@ -40,7 +40,7 @@ app.put(`${route}/asistencia`, (req, res) => { }); // GET -app.put(`${route}/asistentes`, (req, res) => { +app.get(`${route}/asistentes`, (req, res) => { return asistentes(req.query) .then((data) => { res.status(200).json(data);