Merge branch 'master' into dev

This commit is contained in:
Lemuel Márquez
2023-07-25 16:20:48 -06:00
8 changed files with 152 additions and 80 deletions
+28 -24
View File
@@ -41,11 +41,8 @@ const nuevo = async (body, file) => {
const profesor = body.profesor
? validar.validarTexto(body.profesor, 'profesor', true, 50)
: '';
let carpeta = '';
return Usuario.findOne({
where: { idUsuario },
})
return Usuario.findOne({ where: { idUsuario } })
.then((res) => {
if (!res) throw new Error('Este alumno no existe en la db.');
if (res.idTipoUsuario !== 3)
@@ -65,19 +62,7 @@ const nuevo = async (body, file) => {
.then(async (res) => {
if (res)
throw new Error('Este alumno ya tienen un Servicio Social activo.');
return drive.folder(numeroCuenta);
})
.then((res) => {
carpeta = res;
return drive.uploadFile(
path,
`Carta_Aceptacion.pdf`,
'application/pdf',
carpeta
);
})
.then((res) =>
Servicio.create({
return Servicio.create({
idUsuario,
idPrograma,
idCarrera,
@@ -85,15 +70,34 @@ const nuevo = async (body, file) => {
correo,
fechaInicio: fechaInicio.format(),
fechaFin: fechaFin.format(),
carpeta,
cartaAceptacion: res,
carpeta: '',
cartaAceptacion: '',
profesor,
programaInterno,
})
)
.then((res) => ({
message: `Se Pre-Registro correctamente a este alumno alumno.`,
}));
});
})
.then((servicio) => {
let carpeta = '';
drive
.mkDir(numeroCuenta)
.then((res) => {
carpeta = res;
return drive.uploadFile(
path,
`Carta_Aceptacion.pdf`,
'application/pdf',
carpeta
);
})
.then((res) =>
Servicio.update(
{ carpeta, cartaAceptacion: res },
{ where: { idServicio: servicio.idServicio } }
)
);
return { message: `Se Pre-Registro correctamente a este alumno.` };
});
};
module.exports = nuevo;