Compare commits
25 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 30b7922602 | |||
| 19ade37ff0 | |||
| 5b36e324ec | |||
| c4625eff72 | |||
| a5e37b6bac | |||
| 4d125e3d9f | |||
| 384d17c89c | |||
| c6ea621d50 | |||
| 5ad2c05bf0 | |||
| bc18d85b57 | |||
| 173526e695 | |||
| 35ee292138 | |||
| e85e874184 | |||
| 3b5d943abe | |||
| 333d709f1b | |||
| 97f7f3a105 | |||
| 0ce86a74fd | |||
| 72b8ec3a9c | |||
| 11419f6bf4 | |||
| 1545dc98d4 | |||
| c781a9e768 | |||
| aa79d98352 | |||
| 63afcd4448 | |||
| 93ef9fc6a8 | |||
| 8171385a9e |
Vendored
BIN
Binary file not shown.
@@ -0,0 +1,55 @@
|
||||
const { Op } = require('sequelize');
|
||||
const { convertArrayToCSV } = require('convert-array-to-csv');
|
||||
const moment = require('moment');
|
||||
const helperPath = '../../helper';
|
||||
const helper = require(`${helperPath}/helper`);
|
||||
const encriptar = require(`${helperPath}/encriptar`);
|
||||
const dbPath = '../../db/tablas';
|
||||
const Alumno = require(`${dbPath}/Alumno`);
|
||||
const Carrera = require(`${dbPath}/Carrera`);
|
||||
const Horario = require(`${dbPath}/Horario`);
|
||||
|
||||
const csv = async (body) => {
|
||||
const path = `server/uploads/reporte.csv`;
|
||||
const data = [];
|
||||
|
||||
if (
|
||||
!encriptar.comparar(
|
||||
body.password,
|
||||
'$2b$10$hYcczDkvhkcwNo7G80qr3OFsRFXU3tbNBX8Znx.88o2l3nJtOiQi6'
|
||||
)
|
||||
)
|
||||
throw new Error('Contraseña incorrecta.');
|
||||
return Alumno.findAll({
|
||||
where: { idHorario: { [Op.ne]: null } },
|
||||
include: [{ model: Horario }, { model: Carrera }],
|
||||
})
|
||||
.then(async (res) => {
|
||||
for (let i = 0; i < res.length; i++) {
|
||||
const horario = moment(res[i].Horario.horario);
|
||||
|
||||
data.push({
|
||||
numeroCuenta: res[i].numeroCuenta,
|
||||
carrera: res[i].Carrera.carrera,
|
||||
dia: `${
|
||||
horario.date() < 10 ? '0' + horario.date() : horario.date()
|
||||
}/${
|
||||
horario.month() + 1 < 10
|
||||
? '0' + (horario.month() + 1)
|
||||
: horario.month() + 1
|
||||
}/${horario.year()}`,
|
||||
hora: `${
|
||||
horario.hour() < 10 ? '0' + horario.hour() : horario.hour()
|
||||
}:${
|
||||
horario.minute() < 10 ? '0' + horario.minute() : horario.minute()
|
||||
}`,
|
||||
asistio: res[i].asistio ? 'si' : 'no',
|
||||
});
|
||||
}
|
||||
await helper.eliminarArchivo(path).catch((err) => {});
|
||||
return helper.crearArchivo(path, convertArrayToCSV(data));
|
||||
})
|
||||
.then((res) => path);
|
||||
};
|
||||
|
||||
module.exports = csv;
|
||||
@@ -1,6 +1,5 @@
|
||||
const dbPath = '../../db/tablas';
|
||||
const Alumno = require(`${dbPath}/Alumno`);
|
||||
const Carrera = require(`${dbPath}/Carrera`);
|
||||
const Horario = require(`${dbPath}/Horario`);
|
||||
|
||||
const monitor = async () => {
|
||||
@@ -10,14 +9,7 @@ const monitor = async () => {
|
||||
for (let i = 0; i < res.length; i++) {
|
||||
const Asistentes = await Alumno.findAll({
|
||||
where: { idHorario: res[i].idHorario },
|
||||
include: [{ model: Carrera }],
|
||||
}).then((res) => {
|
||||
for (let j = 0; j < res.length; j++) {
|
||||
delete res[j].dataValues.idCarrera;
|
||||
delete res[j].dataValues.idHorario;
|
||||
}
|
||||
return res;
|
||||
});
|
||||
}).then((res) => res.length);
|
||||
|
||||
data.push({ Horario: res[i], Asistentes });
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
const { Op } = require('sequelize');
|
||||
const dbPath = '../../db/tablas';
|
||||
const Alumno = require(`${dbPath}/Alumno`);
|
||||
const Carrera = require(`${dbPath}/Carrera`);
|
||||
|
||||
const monitorCarreras = async () => {
|
||||
const data = [];
|
||||
|
||||
return Carrera.findAll().then(async (res) => {
|
||||
for (let i = 0; i < res.length; i++) {
|
||||
const Asistentes = await Alumno.findAll({
|
||||
where: { idCarrera: res[i].idCarrera, idHorario: { [Op.ne]: null } },
|
||||
}).then((res) => res.length);
|
||||
|
||||
data.push({ Carrera: res[i].carrera, Asistentes });
|
||||
}
|
||||
return data;
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = monitorCarreras;
|
||||
@@ -1,17 +1,11 @@
|
||||
const moment = require('moment');
|
||||
const dbHelper = '../../helper';
|
||||
const gmail = require(`${dbHelper}/gmail`);
|
||||
const { correoAsistencia } = require(`${dbHelper}/correos`);
|
||||
const { validarId } = require(`${dbHelper}/validar`);
|
||||
const dbPath = '../../db/tablas';
|
||||
const Alumno = require(`${dbPath}/Alumno`);
|
||||
const Horario = require(`${dbPath}/Horario`);
|
||||
const ahora = moment();
|
||||
|
||||
const pasarLista = async (body) => {
|
||||
const idAlumno = validarId(body.idAlumno);
|
||||
let correo = {};
|
||||
let horario = moment();
|
||||
|
||||
return Alumno.findOne({
|
||||
where: { idAlumno },
|
||||
@@ -19,25 +13,12 @@ const pasarLista = async (body) => {
|
||||
})
|
||||
.then((res) => {
|
||||
if (!res) throw new Error('No existe este alumno.');
|
||||
horario = moment(res.Horario.horario);
|
||||
if (!res.idHorario)
|
||||
throw new Error('Este alumno no tiene ningún horario asignado.');
|
||||
if (res.asistio) throw new Error('Ya paso lista a este alumno.');
|
||||
if (ahora < horario) throw new Error('Aun no es la hora del recorrido.');
|
||||
horario.add(20, 'm');
|
||||
if (ahora > horario) throw new Error('Ya paso la hora del recorrido.');
|
||||
return Alumno.update({ asistio: true }, { where: { idAlumno } });
|
||||
})
|
||||
.then((res) => {
|
||||
correo = correoAsistencia();
|
||||
return gmail(
|
||||
correo.subject,
|
||||
'lemuelhelonmarquezrosas@gmail.com',
|
||||
correo.message
|
||||
);
|
||||
})
|
||||
.then((res) => {
|
||||
console.log(res);
|
||||
return { message: 'Se paso lista correctamente.' };
|
||||
});
|
||||
.then((res) => ({ message: 'Se paso lista correctamente.' }));
|
||||
};
|
||||
|
||||
module.exports = pasarLista;
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
const dbHelper = '../../helper';
|
||||
const { validarNumeroCuenta } = require(`${dbHelper}/validar`);
|
||||
const dbPath = '../../db/tablas';
|
||||
const Alumno = require(`${dbPath}/Alumno`);
|
||||
const Horario = require(`${dbPath}/Horario`);
|
||||
|
||||
const pasarListaNumeroC = async (body) => {
|
||||
const numeroCuenta = validarNumeroCuenta(body.numeroCuenta);
|
||||
|
||||
return Alumno.findOne({
|
||||
where: { numeroCuenta },
|
||||
include: [{ model: Horario }],
|
||||
})
|
||||
.then((res) => {
|
||||
if (!res) throw new Error('No existe este alumno.');
|
||||
if (!res.idHorario)
|
||||
throw new Error('Este alumno no tiene ningún horario asignado.');
|
||||
if (res.asistio) throw new Error('Ya paso lista a este alumno.');
|
||||
return Alumno.update(
|
||||
{ asistio: true },
|
||||
{ where: { idAlumno: res.idAlumno } }
|
||||
);
|
||||
})
|
||||
.then((res) => ({ message: 'Se paso lista correctamente.' }));
|
||||
};
|
||||
|
||||
module.exports = pasarListaNumeroC;
|
||||
@@ -1,3 +1,4 @@
|
||||
const moment = require('moment');
|
||||
const dbHelper = '../../helper';
|
||||
const { validarId } = require(`${dbHelper}/validar`);
|
||||
const { correoAlumno } = require(`${dbHelper}/correos`);
|
||||
@@ -6,8 +7,10 @@ const dbPath = '../../db/tablas';
|
||||
const Alumno = require(`${dbPath}/Alumno`);
|
||||
const Carrera = require(`${dbPath}/Carrera`);
|
||||
const Horario = require(`${dbPath}/Horario`);
|
||||
const ahora = moment();
|
||||
|
||||
const registrar = async (body) => {
|
||||
throw new Error('Se ha cerrado el registro.');
|
||||
const idHorario = validarId(body.idHorario);
|
||||
const idAlumno = validarId(body.idAlumno);
|
||||
let alumno = {};
|
||||
@@ -30,10 +33,12 @@ const registrar = async (body) => {
|
||||
horario = res;
|
||||
if (alumno.turno != horario.turno)
|
||||
throw new Error('Este horario no corresponde con el turno del alumno.');
|
||||
if (moment(horario.horario).add(20, 'm') < ahora)
|
||||
throw new Error('Ya no puedes incribirte a este horario.');
|
||||
return Alumno.findAll({ where: { idHorario } });
|
||||
})
|
||||
.then((res) => {
|
||||
if (res.length > 50)
|
||||
if (res.length >= 50)
|
||||
throw new Error('Ya no hay espacio en este horario.');
|
||||
return Alumno.update({ idHorario }, { where: { idAlumno } });
|
||||
})
|
||||
@@ -46,14 +51,13 @@ const registrar = async (body) => {
|
||||
);
|
||||
return gmail(
|
||||
correo.subject,
|
||||
'lemuelhelonmarquezrosas@gmail.com',
|
||||
// `${alumno.numeroCuenta@pcpuma.acatlan.unam.mx`
|
||||
`${alumno.numeroCuenta}@pcpuma.acatlan.unam.mx`,
|
||||
correo.message
|
||||
);
|
||||
})
|
||||
.then((res) => ({
|
||||
message:
|
||||
'Se registro correctamente tu horario. Se envio una comprobante a tu correo pcpuma.',
|
||||
'Se registró correctamente tu horario. Se envió un comprobante a tu correo institucional pcpuma.',
|
||||
}));
|
||||
};
|
||||
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
const dbHelper = '../../helper';
|
||||
const { validarId } = require(`${dbHelper}/validar`);
|
||||
const dbPath = '../../db/tablas';
|
||||
const Alumno = require(`${dbPath}/Alumno`);
|
||||
const AlumnoHorario = require(`${dbPath}/AlumnoHorario`);
|
||||
const Horario = require(`${dbPath}/Horario`);
|
||||
|
||||
const reporte = async (body) => {};
|
||||
|
||||
module.exports = reporte;
|
||||
@@ -0,0 +1,31 @@
|
||||
const moment = require('moment');
|
||||
const dbHelper = '../../helper';
|
||||
const { correoAlumno } = require(`${dbHelper}/correos`);
|
||||
const gmail = require(`${dbHelper}/gmail`);
|
||||
const dbPath = '../../db/tablas';
|
||||
const Alumno = require(`${dbPath}/Alumno`);
|
||||
const Carrera = require(`${dbPath}/Carrera`);
|
||||
const Horario = require(`${dbPath}/Horario`);
|
||||
|
||||
const enviar = async (numeroCuenta) => {
|
||||
return Alumno.findOne({
|
||||
where: { numeroCuenta },
|
||||
include: [{ model: Carrera }, { model: Horario }],
|
||||
}).then((res) => {
|
||||
if (!res) throw new Error('No existe este alumno.');
|
||||
|
||||
let correo = correoAlumno(
|
||||
res.numeroCuenta,
|
||||
res.Carrera.carrera,
|
||||
res.Horario.horario,
|
||||
res.idAlumno
|
||||
);
|
||||
return gmail(
|
||||
correo.subject,
|
||||
`${res.numeroCuenta}@pcpuma.acatlan.unam.mx`,
|
||||
correo.message
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
enviar('318359267');
|
||||
@@ -13,7 +13,7 @@ const get = async (body) => {
|
||||
where: { idHorario: res[i].idHorario },
|
||||
});
|
||||
|
||||
if (registrados.length <= 50) data.push(res[i]);
|
||||
if (registrados.length < 50) data.push(res[i]);
|
||||
}
|
||||
return data;
|
||||
});
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
const moment = require('moment');
|
||||
const Alumno = require(`../../db/tablas/Alumno`);
|
||||
const Carrera = require(`../../db/tablas/Carrera`);
|
||||
const Horario = require(`../../db/tablas/Horario`);
|
||||
const ahora = moment();
|
||||
|
||||
const hoy = async (body) => {
|
||||
return Horario.findAll().then(async (res) => {
|
||||
const data = [];
|
||||
|
||||
for (let i = 0; i < res.length; i++) {
|
||||
const horario = moment(res[i].horario);
|
||||
|
||||
if (horario.dayOfYear() === ahora.dayOfYear()) {
|
||||
const Alumnos = await Alumno.findAll({
|
||||
where: { idHorario: res[i].idHorario },
|
||||
include: [{ model: Carrera }],
|
||||
});
|
||||
|
||||
data.push({ Horario: res[i], Alumnos });
|
||||
}
|
||||
}
|
||||
return data;
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = hoy;
|
||||
+14
-10
@@ -26,18 +26,22 @@ const cargaMasiva = async () => {
|
||||
`El alumno ${alumnos[i].numeroCuenta} ya existe. Linea ${i + 2}.`
|
||||
);
|
||||
else {
|
||||
await Alumno.create({
|
||||
numeroCuenta: alumnos[i].numeroCuenta,
|
||||
turno: alumnos[i].turno,
|
||||
idCarrera: carrera.idCarrera,
|
||||
}).then((res) => {
|
||||
if (alumnos[i].inscrito != 'SI')
|
||||
console.log(
|
||||
`Se creo al alumno ${res.numeroCuenta} correctamente. Linea ${
|
||||
i + 2
|
||||
}.`
|
||||
`El alumno ${alumnos[i].numeroCuenta} no esta inscrito.`
|
||||
);
|
||||
if (alumnos[i].inscrito != 'SI') console.log(`No esta inscrito.`);
|
||||
});
|
||||
else
|
||||
await Alumno.create({
|
||||
numeroCuenta: alumnos[i].numeroCuenta,
|
||||
turno: alumnos[i].turno,
|
||||
idCarrera: carrera.idCarrera,
|
||||
}).then((res) => {
|
||||
console.log(
|
||||
`Se creo al alumno ${res.numeroCuenta} correctamente. Linea ${
|
||||
i + 2
|
||||
}.`
|
||||
);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
+13
-34
@@ -5,8 +5,8 @@ const correoAlumno = (numeroCuenta, lic, date, idAlumno) => {
|
||||
|
||||
return {
|
||||
subject: `Comprobante de registro recorrido.`,
|
||||
message: `<h2>Estimada(o) alumna(o)</h2>
|
||||
<h3><b>Alumna(o) de la Generación 2021</b>,<br>Licenciatura: <b>${lic}</b></h3>
|
||||
message: `<h2>Estimada(o) alumna(o) de la Generación 2021,</h2>
|
||||
<h3>Licenciatura: <b>${lic}</b></h3>
|
||||
|
||||
<div style="font-size: 15px;">
|
||||
<p>
|
||||
@@ -20,38 +20,26 @@ const correoAlumno = (numeroCuenta, lic, date, idAlumno) => {
|
||||
}:${
|
||||
fecha.minute() < 10 ? '0' + fecha.minute() : fecha.minute()
|
||||
} h</b>. Te pedimos
|
||||
asistir en la fecha y horarios asignados de acuerdo con tu licenciatura (no pueden ser modificados).
|
||||
asistir en la fecha y horarios elegidos (no puedes modificarlos).
|
||||
</p>
|
||||
|
||||
<p>Te solicitamos atender las siguientes medidas:</p>
|
||||
|
||||
<p>
|
||||
⮚ Programa tu llegada 10 min. antes de la hora de tu cita.
|
||||
</p>
|
||||
<ul>
|
||||
<li>Programa tu llegada 10 min. antes de la hora de tu cita.</li>
|
||||
|
||||
<p>
|
||||
⮚ El uso de cubrebocas es obligatorio en todo momento.
|
||||
</p>
|
||||
<li>El uso de cubrebocas es obligatorio en todo momento.</li>
|
||||
|
||||
<p>
|
||||
⮚ Presenta al ingreso este “Comprobante de registro para recorrido”, puede ser en formato impreso o digital.
|
||||
</p>
|
||||
<li>Presenta al ingreso este “Comprobante de registro para recorrido”, puede ser en formato impreso o digital.</li>
|
||||
|
||||
<p>
|
||||
⮚ No se permitirán acompañantes durante el recorrido.
|
||||
</p>
|
||||
<li>No se permitirán acompañantes durante el recorrido.</li>
|
||||
|
||||
<p>
|
||||
⮚ Acude con ropa cómoda y agua para estar bien hidratada(o).
|
||||
</p>
|
||||
<li>Acude con ropa cómoda y agua para estar bien hidratada(o).</li>
|
||||
|
||||
<p>
|
||||
⮚ Si acudes en auto, sólo se permitirá tu ingreso (sin acompañantes) por el acceso vehicular sobre la avenida San Juan Totoltepec, junto a la Plaza San Mateo.
|
||||
</p>
|
||||
<li>Si acudes en auto, sólo se permitirá tu ingreso (sin acompañantes) por el acceso vehicular sobre la avenida San Juan Totoltepec, junto a la Plaza San Mateo.</li>
|
||||
</ul>
|
||||
|
||||
<p>
|
||||
¡Estaremos felices de recibirte!
|
||||
</p>
|
||||
<p>¡Estaremos felices de recibirte!</p>
|
||||
|
||||
<img src="https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=https://api.qrserver.com/v1/create-qr-code/?size=200x200&data={%22numeroCuenta%22:%22${numeroCuenta}%22,%22idAlumno%22:${idAlumno}}" alt="qr_img" />
|
||||
|
||||
@@ -63,13 +51,4 @@ const correoAlumno = (numeroCuenta, lic, date, idAlumno) => {
|
||||
};
|
||||
};
|
||||
|
||||
const correoAsistencia = (numeroCuenta, lic, date) => {
|
||||
// const fecha = moment(date);
|
||||
|
||||
return {
|
||||
subject: `Comprobante de asistencia recorrido.`,
|
||||
message: `Asistencia uwu.`,
|
||||
};
|
||||
};
|
||||
|
||||
module.exports = { correoAlumno, correoAsistencia };
|
||||
module.exports = { correoAlumno };
|
||||
|
||||
@@ -2,10 +2,24 @@ const express = require('express');
|
||||
const app = express();
|
||||
const route = '/alumno';
|
||||
const controllerPath = '../controller/Alumno';
|
||||
const csv = require(`${controllerPath}/csv`);
|
||||
const get = require(`${controllerPath}/get`);
|
||||
const monitor = require(`${controllerPath}/monitor`);
|
||||
const monitorCarreras = require(`${controllerPath}/monitorCarreras`);
|
||||
const registrar = require(`${controllerPath}/registrar`);
|
||||
const pasarLista = require(`${controllerPath}/pasarLista`);
|
||||
const pasarListaNumeroC = require(`${controllerPath}/pasarListaNumeroC`);
|
||||
|
||||
// POST
|
||||
app.post(`${route}/csv`, (req, res) => {
|
||||
return csv(req.body)
|
||||
.then((data) => {
|
||||
res.download(data);
|
||||
})
|
||||
.catch((err) => {
|
||||
res.status(400).json({ message: err.message });
|
||||
});
|
||||
});
|
||||
|
||||
// PUT
|
||||
app.put(`${route}/registrar`, (req, res) => {
|
||||
@@ -28,6 +42,16 @@ app.put(`${route}/pasar_lista`, (req, res) => {
|
||||
});
|
||||
});
|
||||
|
||||
app.put(`${route}/pasar_lista_numero_c`, (req, res) => {
|
||||
return pasarListaNumeroC(req.body)
|
||||
.then((data) => {
|
||||
res.status(200).json(data);
|
||||
})
|
||||
.catch((err) => {
|
||||
res.status(400).json({ message: err.message });
|
||||
});
|
||||
});
|
||||
|
||||
// GET
|
||||
app.get(`${route}`, (req, res) => {
|
||||
return get(req.query)
|
||||
@@ -49,4 +73,14 @@ app.get(`${route}/monitor`, (req, res) => {
|
||||
});
|
||||
});
|
||||
|
||||
app.get(`${route}/monitor_carreras`, (req, res) => {
|
||||
return monitorCarreras()
|
||||
.then((data) => {
|
||||
res.status(200).json(data);
|
||||
})
|
||||
.catch((err) => {
|
||||
res.status(400).json({ message: err.message });
|
||||
});
|
||||
});
|
||||
|
||||
module.exports = app;
|
||||
|
||||
@@ -3,6 +3,7 @@ const app = express();
|
||||
const route = '/horario';
|
||||
const controllerPath = '../controller/Horario';
|
||||
const get = require(`${controllerPath}/get`);
|
||||
const hoy = require(`${controllerPath}/hoy`);
|
||||
|
||||
// GET
|
||||
app.get(`${route}`, (req, res) => {
|
||||
@@ -15,4 +16,14 @@ app.get(`${route}`, (req, res) => {
|
||||
});
|
||||
});
|
||||
|
||||
app.get(`${route}/horarios_hoy`, (req, res) => {
|
||||
return hoy(req.query)
|
||||
.then((data) => {
|
||||
res.status(200).json(data);
|
||||
})
|
||||
.catch((err) => {
|
||||
res.status(400).json({ message: err.message });
|
||||
});
|
||||
});
|
||||
|
||||
module.exports = app;
|
||||
|
||||
Reference in New Issue
Block a user