diff --git a/package-lock.json b/package-lock.json index 33439e3..65a2f26 100644 --- a/package-lock.json +++ b/package-lock.json @@ -234,6 +234,25 @@ "node": ">= 6" } }, + "node_modules/are-we-there-yet/node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, "node_modules/are-we-there-yet/node_modules/string_decoder": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", @@ -3162,6 +3181,11 @@ "util-deprecate": "^1.0.1" } }, + "safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==" + }, "string_decoder": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", diff --git a/server/controller/Servicio/admin.js b/server/controller/Servicio/admin.js index c9227e2..78eba42 100644 --- a/server/controller/Servicio/admin.js +++ b/server/controller/Servicio/admin.js @@ -16,12 +16,13 @@ const admin = async (body) => { { model: Usuario, include: [{ model: TipoUsuario }] }, { model: Carrera }, { model: Status }, - { model: Programa }, + { model: Programa, include: [{ model: Usuario }] }, ], }).then((res) => { if (!res) throw new Error('No existe este servicio social.'); delete res.dataValues.Usuario.dataValues.password; delete res.dataValues.Programa.dataValues.idUsuario; + delete res.dataValues.Programa.dataValues.Usuario.dataValues.password; delete res.dataValues.idUsuario; delete res.dataValues.idCarrera; delete res.dataValues.idStatus; diff --git a/server/controller/Usuario/escolares.js b/server/controller/Usuario/escolares.js index ea04b1b..78a15b6 100644 --- a/server/controller/Usuario/escolares.js +++ b/server/controller/Usuario/escolares.js @@ -4,6 +4,33 @@ const { validarNumeroCuenta } = require('../../helper/validar'); const dbPath = '../../db/tablas'; const Usuario = require(`${dbPath}/Usuario`); const Carrera = require(`${dbPath}/Carrera`); +const creditosCarreras = [ + { carrera: 'LIC. EN ACTUARIA', creditos: 70 }, + { carrera: 'LIC. EN ARQUITECTURA', creditos: 70 }, + { carrera: 'LIC. EN CIENCIAS POLITICAS Y ADMON PUB', creditos: 70 }, + { carrera: 'LIC. EN CIENCIAS POLITICAS Y ADMON.PUBL.', creditos: 70 }, + { carrera: 'LIC. EN COMUNICACION', creditos: 67 }, + { carrera: 'LIC. EN DERECHO', creditos: 70 }, + { carrera: 'LIC. EN DERECHO (SUA)', creditos: 70 }, + { carrera: 'LIC. EN DISEÑO GRAFICO', creditos: 70 }, + { carrera: 'LIC. EN ECONOMIA', creditos: 70 }, + { carrera: 'LIC. EN ENSEÑANZA DE INGLES', creditos: 70 }, + { carrera: 'LIC. EN FILOSOFIA', creditos: 70 }, + { carrera: 'LIC. EN HISTORIA', creditos: 70 }, + { carrera: 'LIC. EN INGENIERIA CIVIL', creditos: 70 }, + { carrera: 'LIC. EN LENGUA Y LITERATURA HISPANICAS', creditos: 70 }, + { carrera: 'LIC. EN MAT. APLICADAS Y COMPUTACION', creditos: 68 }, + { carrera: 'LIC. EN MATEMATICAS APLICADAS Y COMP.', creditos: 68 }, + { carrera: 'LIC. EN PEDAGOGÍA', creditos: 70 }, + { carrera: 'LIC. EN PERIODISMO Y COMUNICACION COL.', creditos: 70 }, + { carrera: 'LIC. EN RELACIONES INTERNACIONALES', creditos: 70 }, + { carrera: 'LIC. EN RELACIONES INTERNACIONALES (SUA)', creditos: 70 }, + { carrera: 'LIC. EN SOCIOLOGIA', creditos: 70 }, + { carrera: 'LIC. ENSEÑANZA DE ALEMÁN (LENG. EXTRANJS', creditos: 70 }, + { carrera: 'LIC. ENSEÑANZA DE ESPAÑOL(LENG. EXTRANJ)', creditos: 70 }, + { carrera: 'LIC. ENSEÑANZA DE INGLÉS(LENG. EXTRANJE)', creditos: 70 }, + { carrera: 'LIC. ENSEÑANZA DE ITALIANO(LENG. EXTRANJ', creditos: 70 }, +]; const escolares = async (body) => { const numeroCuenta = validarNumeroCuenta(body.numeroCuenta); @@ -17,18 +44,26 @@ const escolares = async (body) => { .then((res) => { if (!res.data.nombre || !res.data.carrconst || !res.data.avance) throw new Error( - 'El alumno no cumple con los requisitos para realizar el Servicio Social. Si cree que esto es erroneo comunicate con COESI.' + 'El alumno no cumple con los requisitos para realizar el Servicio Social. Si cree que esto es erróneo comunícate al Departamento de Servicio Social y Bolsa de Trabajo.' ); alumno = { nombre: res.data.nombre.trim(), creditos: res.data.avance, carrera: res.data.carrconst.trim(), }; - while (alumno.nombre.search('‘') != -1) - alumno.nombre = alumno.nombre.replace('‘', ''); - while (alumno.nombre.search('Ã') != -1) + for (let i = 0; i < creditosCarreras.length; i++) + if ( + alumno.carrera === creditosCarreras[i].carrera && + Number(alumno.creditos) < creditosCarreras[i].creditos + ) + throw new Error('Este alumno no cuenta con los créditos necesarios.'); + while ( + alumno.nombre.search('‘') != -1 && + alumno.nombre.search('Ã') != -1 + ) { alumno.nombre = alumno.nombre.replace('Ã', 'Ñ'); - + alumno.nombre = alumno.nombre.replace('‘', ''); + } return Carrera.findOne({ where: { carrera: alumno.carrera } }); }) .then((res) => {