ya no deberían haber duplicados
This commit is contained in:
@@ -36,7 +36,7 @@ const liberacion = async (body) => {
|
||||
.then((res) => CasoEspecial.update(update, { where: { idCasoEspecial } }))
|
||||
.then((res) => ({
|
||||
message:
|
||||
'Se cambio de estatus correctamente y se envio un correo al alumno informandole de su liberación.',
|
||||
'Se cambió de estatus correctamente y se envió un correo al alumno informandole de su liberación.',
|
||||
}));
|
||||
};
|
||||
|
||||
|
||||
@@ -41,7 +41,6 @@ const nuevo = async (body, file) => {
|
||||
const profesor = body.profesor
|
||||
? validar.validarTexto(body.profesor, 'profesor', true, 50)
|
||||
: '';
|
||||
let carpeta = '';
|
||||
|
||||
return Usuario.findOne({
|
||||
where: { idUsuario },
|
||||
@@ -65,19 +64,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 +72,38 @@ 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
|
||||
.folder(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 } }
|
||||
)
|
||||
)
|
||||
.then((res) => {
|
||||
console.log(res);
|
||||
console.log("Se subió el archivo");
|
||||
});
|
||||
return { message: `Se Pre-Registro correctamente a este alumno alumno.` };
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = nuevo;
|
||||
|
||||
+28
-6
@@ -144,15 +144,37 @@ const folder = async (numeroCuenta) => {
|
||||
return mkDir(numeroCuenta);
|
||||
};
|
||||
|
||||
const borrarTodo = () => {
|
||||
return list().then(async (res) => {
|
||||
for (let i = 0; i < res.files.length; i++)
|
||||
if (res.files[i].id !== process.env.CARPETA)
|
||||
await deleteFile(res.files[i].id);
|
||||
});
|
||||
// const borrarTodo = () => {
|
||||
// return list().then(async (res) => {
|
||||
// for (let i = 0; i < res.files.length; i++)
|
||||
// if (res.files[i].id !== process.env.CARPETA)
|
||||
// await deleteFile(res.files[i].id);
|
||||
// });
|
||||
// };
|
||||
|
||||
const findAll = async () => {
|
||||
const folders = [];
|
||||
const pdfs = [];
|
||||
let pageToken = '';
|
||||
|
||||
do {
|
||||
await list(pageToken).then((res) => {
|
||||
for (let i = 0; i < res.files.length; i++) {
|
||||
if (res.files[i].id !== process.env.CARPETA) {
|
||||
if (res.files[i].mimeType === 'application/vnd.google-apps.folder')
|
||||
folders.push(res.files[i].id);
|
||||
if (res.files[i].mimeType === 'application/pdf')
|
||||
pdfs.push(res.files[i].id);
|
||||
}
|
||||
}
|
||||
pageToken = res.nextPageToken ? res.nextPageToken : '';
|
||||
});
|
||||
} while (pageToken);
|
||||
return { folders, pdfs };
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
folder,
|
||||
uploadFile,
|
||||
findAll,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user