using cuestionario2 has atribute, create credentials for testing
This commit is contained in:
+1
-1
@@ -11,7 +11,7 @@ COPY package*.json ./
|
||||
RUN npm install
|
||||
|
||||
# Copia el código fuente de la aplicación
|
||||
COPY . .
|
||||
COPY . .
|
||||
|
||||
# Expone el puerto que la app usará
|
||||
EXPOSE 3000
|
||||
|
||||
@@ -255,13 +255,29 @@ console.log("datos a registrar en la tabla cuestionarioAlumno2", { ...body, idC
|
||||
|
||||
let respuestasRegistradas = await CuestionarioAlumno2.create({ ...body, idCuestionario: cuestionarioRegistro.idCuestionario });
|
||||
console.log('despues de registrar cuestionario', respuestasRegistradas);
|
||||
|
||||
|
||||
console.log('cuestionario registrado', cuestionarioRegistro);
|
||||
|
||||
|
||||
|
||||
|
||||
console.log('agregar el id a la tabla servicio, esta validado en el front');
|
||||
|
||||
let resX = await Servicio.update(
|
||||
{ idCuestionarioAlumno2: respuestasRegistradas.idCuestionarioAlumno2},
|
||||
{ where: { idServicio } }
|
||||
)
|
||||
|
||||
console.log('despues de registrar el id en la tabla servicio', resX);
|
||||
|
||||
|
||||
|
||||
return cuestionarioRegistro;
|
||||
})
|
||||
|
||||
|
||||
.then((res) => validar.validarPreTermino(idServicio))
|
||||
|
||||
|
||||
.then((res) => ({
|
||||
message: `Se guardaron tus respuestas correctamente. ${res}`,
|
||||
}));
|
||||
|
||||
@@ -155,7 +155,7 @@ const nuevo = async (body) => {
|
||||
|
||||
let cuestionarioRegistro = await Cuestionario.create({
|
||||
idServicio,
|
||||
idCuestionarioPrograma: respuestasRegistradas.idCuestionarioPrograma,
|
||||
//idCuestionarioPrograma: respuestasRegistradas.idCuestionarioPrograma,
|
||||
version: '2',
|
||||
dirigidoA: 'programas',
|
||||
titulo: 'Cuestionario de programa v2',
|
||||
@@ -180,9 +180,26 @@ const nuevo = async (body) => {
|
||||
// si el cuestionario ya existe solo hay que actualizar el id de cuestionarioprograma o alumno
|
||||
|
||||
|
||||
console.log("registrar id en servicio en cuestionario 2");
|
||||
|
||||
let x = await Servicio.update(
|
||||
{ idCuestionarioPrograma2: respuestasRegistradas.idCuestionarioPrograma2 },
|
||||
{ where: { idServicio } }
|
||||
)
|
||||
|
||||
console.log(x);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return cuestionarioRegistro;
|
||||
})
|
||||
|
||||
.then((res) => validar.validarPreTermino(idServicio))
|
||||
|
||||
|
||||
.then((res) => ({
|
||||
message: `Se guardaron tus respuestas correctamente. ${res}`,
|
||||
}));
|
||||
|
||||
@@ -56,7 +56,9 @@ const admin = async (body) => {
|
||||
'vistoBuenoAcatlan',
|
||||
'createdAt',
|
||||
'idCuestionarioAlumno',
|
||||
'idCuestionarioAlumno2',
|
||||
'idCuestionarioPrograma',
|
||||
'idCuestionarioPrograma2'
|
||||
],
|
||||
}).then((res) => {
|
||||
if (!res) throw new Error('No existe este servicio social.');
|
||||
|
||||
@@ -46,6 +46,7 @@ const alumno = async (body) => {
|
||||
'profesor',
|
||||
'createdAt',
|
||||
'idCuestionarioAlumno',
|
||||
'idCuestionarioAlumno2'
|
||||
],
|
||||
});
|
||||
})
|
||||
|
||||
@@ -24,12 +24,14 @@ const cartaTermino = async (body, file) => {
|
||||
switch (res.idStatus) {
|
||||
case 4:
|
||||
case 8:
|
||||
return drive.uploadFile(
|
||||
return drive.uploadFile(
|
||||
path,
|
||||
`Carta_Termino.pdf`,
|
||||
'application/pdf',
|
||||
res.carpeta
|
||||
);
|
||||
);
|
||||
//return "carta de termino"
|
||||
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
|
||||
@@ -24,12 +24,13 @@ const informeGlobal = async (body, file) => {
|
||||
switch (res.idStatus) {
|
||||
case 4:
|
||||
case 9:
|
||||
return drive.uploadFile(
|
||||
return drive.uploadFile(
|
||||
path,
|
||||
`Informe_Global.pdf`,
|
||||
'application/pdf',
|
||||
res.carpeta
|
||||
);
|
||||
);
|
||||
// return "informe global"
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
|
||||
@@ -79,7 +79,7 @@ const nuevo = async (body, file) => {
|
||||
.then((servicio) => {
|
||||
let carpeta = '';
|
||||
|
||||
drive
|
||||
drive
|
||||
.mkDir(numeroCuenta)
|
||||
.then((res) => {
|
||||
carpeta = res;
|
||||
@@ -95,7 +95,7 @@ const nuevo = async (body, file) => {
|
||||
{ carpeta, cartaAceptacion: res },
|
||||
{ where: { idServicio: servicio.idServicio } }
|
||||
)
|
||||
);
|
||||
);
|
||||
return { message: `Se Pre-Registro correctamente a este alumno.` };
|
||||
});
|
||||
};
|
||||
|
||||
@@ -12,7 +12,9 @@ const registro = async (body) => {
|
||||
body.idServicio,
|
||||
'id servicio'
|
||||
);
|
||||
const password = encriptar.generarPassword();
|
||||
//const password = encriptar.generarPassword(); // esta genera la contraseña
|
||||
let pass = 'qwertyui'
|
||||
const password = pass //encriptar.encriptar(pass)
|
||||
let correo = {};
|
||||
let idUsuario;
|
||||
|
||||
@@ -58,6 +60,7 @@ const registro = async (body) => {
|
||||
.then((res) => ({
|
||||
message:
|
||||
'Se cambio de estatus correctamente y se envio un correo al alumno con sus credenciales.',
|
||||
pass
|
||||
}));
|
||||
};
|
||||
|
||||
|
||||
@@ -78,13 +78,19 @@ const registroValidado = async (body) => {
|
||||
gmail(correoResponsable.subject, emailResponsable, correoResponsable.msj)
|
||||
)
|
||||
.then((res) =>
|
||||
Servicio.update(
|
||||
{
|
||||
|
||||
let tempStatus = 3
|
||||
if (process.env.MODE == "pruebas") tempStatus = 4
|
||||
|
||||
return Servicio.update(
|
||||
// Producción
|
||||
{ idStatus: 3, direccion, telefono, fechaNacimiento },
|
||||
// { idStatus: 3, direccion, telefono, fechaNacimiento },
|
||||
// Pruebas
|
||||
// { idStatus: 4, direccion, telefono, fechaNacimiento },
|
||||
{ idStatus: tempStatus, direccion, telefono, fechaNacimiento },
|
||||
{ where: { idServicio } }
|
||||
)
|
||||
}
|
||||
)
|
||||
.then((res) => ({
|
||||
message: 'Haz terminado el registro de tu Servicio Social correctamente.',
|
||||
|
||||
@@ -57,6 +57,7 @@ const serviciosResponsable = async (body) => {
|
||||
'cartaTermino',
|
||||
'createdAt',
|
||||
'idCuestionarioPrograma',
|
||||
'idCuestionarioPrograma2'
|
||||
],
|
||||
order: [['updatedAt', 'DESC']],
|
||||
limit: 25,
|
||||
|
||||
@@ -36,24 +36,31 @@ const escolares = async (body) => {
|
||||
const numeroCuenta = validarNumeroCuenta(body.numeroCuenta);
|
||||
let alumno;
|
||||
|
||||
/*
|
||||
return axios({
|
||||
method: 'post',
|
||||
url: `${process.env.ESCOLARES}${numeroCuenta}`,
|
||||
data: `${process.env.ESCOLARES_PASS}`,
|
||||
})
|
||||
|
||||
*/
|
||||
let promise;
|
||||
|
||||
return new Promise((res) => {
|
||||
res({
|
||||
data:{
|
||||
nombre:"nombre",
|
||||
carrconst:"Carrera",
|
||||
avance:"avance"
|
||||
}
|
||||
if(process.env.MODE == "pruebas"){
|
||||
promise = new Promise((res) => {
|
||||
res({
|
||||
data:{
|
||||
nombre:"nombre",
|
||||
carrconst:"Carrera",
|
||||
avance:"80"
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
else{
|
||||
promise = axios({
|
||||
method: 'post',
|
||||
url: `${process.env.ESCOLARES}${numeroCuenta}`,
|
||||
data: `${process.env.ESCOLARES_PASS}`,
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
return promise
|
||||
|
||||
|
||||
.then((res) => {
|
||||
if (!res.data.nombre || !res.data.carrconst || !res.data.avance)
|
||||
|
||||
@@ -35,7 +35,7 @@ Cuestionario.init(
|
||||
}
|
||||
);
|
||||
|
||||
Cuestionario.belongsTo(Servicio, { foreignKey: 'idServicio' });
|
||||
/* Cuestionario.belongsTo(Servicio, { foreignKey: 'idServicio' });
|
||||
Servicio.hasMany(Cuestionario, { foreignKey: 'idServicio' });
|
||||
|
||||
*/
|
||||
module.exports = Cuestionario;
|
||||
|
||||
@@ -7,6 +7,9 @@ const Status = require('./Status');
|
||||
const CuestionarioAlumno = require('./CuestionarioAlumno');
|
||||
const CuestionarioPrograma = require('./CuestionarioPrograma');
|
||||
|
||||
const CuestionarioAlumno2 = require('./CuestionarioAlumno2');
|
||||
const CuestionarioPrograma2 = require('./CuestionarioPrograma2');
|
||||
|
||||
class Servicio extends Model {}
|
||||
Servicio.init(
|
||||
{
|
||||
@@ -146,4 +149,26 @@ Servicio.belongsTo(CuestionarioPrograma, {
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
Servicio.belongsTo(CuestionarioAlumno2, {
|
||||
foreignKey: {
|
||||
name: 'idCuestionarioAlumno2',
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: true,
|
||||
defaultValue: null,
|
||||
},
|
||||
});
|
||||
|
||||
Servicio.belongsTo(CuestionarioPrograma2, {
|
||||
foreignKey: {
|
||||
name: 'idCuestionarioPrograma2',
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: true,
|
||||
defaultValue: null,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
module.exports = Servicio;
|
||||
|
||||
+26
-1
@@ -10,15 +10,34 @@ const { google } = require('googleapis');
|
||||
// ['https://www.googleapis.com/auth/drive']
|
||||
// );
|
||||
|
||||
const loadCredentials = () => {
|
||||
/* const loadCredentials = () => {
|
||||
try {
|
||||
const credenciales = JSON.parse(fs.readFileSync('./cred.json', 'utf8'));
|
||||
return google.auth.fromJSON(credenciales);
|
||||
} catch (err) {
|
||||
return null;
|
||||
}
|
||||
}; */
|
||||
|
||||
|
||||
const loadCredentials = () => {
|
||||
try {
|
||||
const credenciales = JSON.parse(fs.readFileSync('./cred.json', 'utf8'));
|
||||
credenciales.private_key = credenciales.private_key.replace(/\\n/g, '\n'); // Asegurar formato correcto
|
||||
return new google.auth.JWT(
|
||||
credenciales.client_email,
|
||||
null,
|
||||
credenciales.private_key,
|
||||
['https://www.googleapis.com/auth/drive']
|
||||
);
|
||||
} catch (err) {
|
||||
console.error('❌ Error cargando credenciales:', err);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
const list = (pageToken) => {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
// jwtClient.authorize((err, tokens) => {
|
||||
@@ -127,6 +146,12 @@ const mkDir = (name) => {
|
||||
requestBody,
|
||||
},
|
||||
(err, res) => {
|
||||
console.log(err);
|
||||
console.log("variable res ");
|
||||
|
||||
console.log(res);
|
||||
|
||||
|
||||
if (err) reject(err);
|
||||
resolve(res.data.id);
|
||||
}
|
||||
|
||||
@@ -6,16 +6,16 @@ const send = require('gmail-send')({
|
||||
});
|
||||
|
||||
const gmail = (subject, to, text) => {
|
||||
/*
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
send({ subject, to, text }, (error, result, fullResult) => {
|
||||
if (error) reject(error);
|
||||
resolve(result);
|
||||
});
|
||||
});
|
||||
*/
|
||||
|
||||
|
||||
return "envio de correo"
|
||||
// return "envio de correo"
|
||||
|
||||
|
||||
};
|
||||
|
||||
@@ -178,15 +178,21 @@ const validarPreTermino = (idServicio) => {
|
||||
|
||||
// validar el if
|
||||
|
||||
console.log("este es el id en la busqieda", idServicio);
|
||||
|
||||
|
||||
return Servicio.findOne({ where: { idServicio } })
|
||||
.then((res) => {
|
||||
|
||||
console.log("validando pre termino", res);
|
||||
|
||||
|
||||
if (
|
||||
res.idCuestionarioPrograma &&
|
||||
res.idCuestionarioAlumno &&
|
||||
(res.idCuestionarioPrograma || res.idCuestionarioPrograma2) &&
|
||||
(res.idCuestionarioAlumno || res.idCuestionarioAlumno2) &&
|
||||
res.cartaTermino &&
|
||||
res.informeGlobal
|
||||
)
|
||||
return Servicio.update({ idStatus: 5 }, { where: { idServicio } });
|
||||
) return Servicio.update({ idStatus: 5 }, { where: { idServicio } });
|
||||
return false;
|
||||
})
|
||||
.then((res) =>
|
||||
|
||||
@@ -5,6 +5,8 @@ const route = '/status';
|
||||
const get = require('../controller/Status/get');
|
||||
|
||||
app.get(`${route}`, verificaToken, (req, res) => {
|
||||
console.log("status");
|
||||
|
||||
return get()
|
||||
.then((data) => {
|
||||
res.status(200).json(data);
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
const { google } = require('googleapis');
|
||||
const fs = require('fs');
|
||||
|
||||
const credenciales = JSON.parse(fs.readFileSync('./cred.json', 'utf8'));
|
||||
|
||||
// Asegurar que la clave privada tiene los saltos de línea correctos
|
||||
credenciales.private_key = credenciales.private_key.replace(/\\n/g, '\n');
|
||||
|
||||
const jwtClient = new google.auth.JWT(
|
||||
credenciales.client_email,
|
||||
null,
|
||||
credenciales.private_key,
|
||||
['https://www.googleapis.com/auth/drive']
|
||||
);
|
||||
|
||||
jwtClient.authorize((err, tokens) => {
|
||||
if (err) {
|
||||
console.error('❌ Error de autenticación:', err);
|
||||
} else {
|
||||
console.log('✅ Autenticación exitosa:', tokens);
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,28 @@
|
||||
const { google } = require('googleapis');
|
||||
const fs = require('fs');
|
||||
|
||||
const credenciales = JSON.parse(fs.readFileSync('./cred.json', 'utf8'));
|
||||
credenciales.private_key = credenciales.private_key.replace(/\\n/g, '\n');
|
||||
|
||||
const jwtClient = new google.auth.JWT(
|
||||
credenciales.client_email,
|
||||
null,
|
||||
credenciales.private_key,
|
||||
['https://www.googleapis.com/auth/drive']
|
||||
);
|
||||
|
||||
const drive = google.drive({ version: 'v3', auth: jwtClient });
|
||||
|
||||
async function listFiles() {
|
||||
try {
|
||||
const res = await drive.files.list({
|
||||
pageSize: 10,
|
||||
fields: 'files(id, name)',
|
||||
});
|
||||
console.log('✅ Archivos en Drive:', res.data.files);
|
||||
} catch (error) {
|
||||
console.error('❌ Error al listar archivos:', error);
|
||||
}
|
||||
}
|
||||
|
||||
listFiles();
|
||||
@@ -0,0 +1,35 @@
|
||||
const { google } = require('googleapis');
|
||||
const fs = require('fs');
|
||||
|
||||
const credenciales = JSON.parse(fs.readFileSync('./cred.json', 'utf8'));
|
||||
credenciales.private_key = credenciales.private_key.replace(/\\n/g, '\n');
|
||||
|
||||
const jwtClient = new google.auth.JWT(
|
||||
credenciales.client_email,
|
||||
null,
|
||||
credenciales.private_key,
|
||||
['https://www.googleapis.com/auth/drive']
|
||||
);
|
||||
|
||||
const drive = google.drive({ version: 'v3', auth: jwtClient });
|
||||
|
||||
async function createFolder() {
|
||||
try {
|
||||
const fileMetadata = {
|
||||
name: 'Nueva Carpeta',
|
||||
mimeType: 'application/vnd.google-apps.folder',
|
||||
parents: ['1VXTC9J3dnN7YGNwVxXa4Re4dsjFupLdf'], // Asegúrate de que este ID sea correcto
|
||||
};
|
||||
|
||||
const folder = await drive.files.create({
|
||||
resource: fileMetadata,
|
||||
fields: 'id',
|
||||
});
|
||||
|
||||
console.log('✅ Carpeta creada con ID:', folder.data.id);
|
||||
} catch (error) {
|
||||
console.error('❌ Error al crear carpeta:', error);
|
||||
}
|
||||
}
|
||||
|
||||
createFolder();
|
||||
+13
@@ -501,6 +501,19 @@ ALTER TABLE `cuestionario_alumno_2` ADD FOREIGN KEY (`idCuestionario`) REFERENCE
|
||||
ALTER TABLE `cuestionario_programa` ADD FOREIGN KEY (`idCuestionario`) REFERENCES `Cuestionario` (`idCuestionario`);
|
||||
ALTER TABLE `cuestionario_programa_2` ADD FOREIGN KEY (`idCuestionario`) REFERENCES `Cuestionario` (`idCuestionario`);
|
||||
|
||||
|
||||
-- agregar una columna de cuestionario 2
|
||||
|
||||
ALTER TABLE servicio ADD COLUMN idCuestionarioAlumno2 INT;
|
||||
ALTER TABLE servicio ADD COLUMN idCuestionarioPrograma2 INT;
|
||||
|
||||
ALTER TABLE `servicio` ADD FOREIGN KEY (`idCuestionarioAlumno2`) REFERENCES `cuestionario_alumno_2` (`idCuestionarioAlumno2`);
|
||||
ALTER TABLE `servicio` ADD FOREIGN KEY (`idCuestionarioPrograma2`) REFERENCES `cuestionario_programa_2` (`idCuestionarioPrograma2`);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
--ALTER TABLE `Cuestionario`
|
||||
--ADD FOREIGN KEY (`idCuestionarioAlumno`) REFERENCES `cuestionario_alumno_2` (`idCuestionarioAlumno2`);
|
||||
--ALTER TABLE `Cuestionario`
|
||||
|
||||
Reference in New Issue
Block a user