notification email on student unlinking

parent 65a0a7aa
......@@ -466,12 +466,41 @@ module.exports = {
student: req.param('id_stu'),
supervisor: req.param('id_sup')
})
.populate('supervisor')
.then((stuSup) => {
if (!stuSup)
throw new Error("student and supervisor are not linked");
return [stupStup, Student.findOne(req.params.id_stu).populate('license')];
.spread((stuSup, student) => {
stuSup.destroy();
//
// Mail to supervisor to be notified
//
student = student.toJSON();
if (student.license && student.license.number) {
mailService.mailer()
.send({
to: stuSup.supervisor.email,
text: sails.__(
{
phrase: 'student_unlinked',
locale: stuSup.supervisor.lang
},
{
name: student.name,
surname: student.surname,
license: student.license.number
})
});
.then(() => {})
.catch((err) => {});
}
//
// Broadcast event
//
const socketToOmit = req.isSocket ? req.socket : undefined;
const unlinkSupervisorFromStudentEvent = sails.hooks.events.unlinkSupervisorFromStudent(
stuSup.student,
......
{
"Welcome": "Welcome",
"A brand new app.": "A brand new app.",
"change_password_mail": "To change your password, please click on the following link:\n",
"login": "login",
"notification_from_pictogram": "Notification from Pictogram",
"no_name": "No name",
"no_surname": "No surname",
"office_link": "The office/center \"{{ name }}\" with email \"{{ email }}\" has added you as part of its team in Pictogram.",
"signin_mail": "To activate your Pictogram account, click on this link:\n",
"change_password_mail": "To change your password, please click on the following link:\n",
"login": "login",
"student_unlinked": "You have lost the link to the student {{ name }} {{ surname }}, with license number {{ license }}.",
"therapist_office_request": "{{ name }}, with email {{ email }}, is requesting to be linked as therapist to any of your students.",
"tutor_office_request": "{{ name }}, with email {{ email }}, is requesting to be linked as tutor/father/mother to any of your students.",
"Welcome": "Welcome",
"welcome_msg1": "Welcome to Pictogram, {{ name }}!",
"welcome_msg2": "Your account is now active. You can proceed to",
"office_link": "The office/center \"{{ name }}\" with email \"{{ email }}\" has added you as part of its team in Pictogram."
}
{
"Welcome": "Bienvenido",
"A brand new app.": "Una aplicación de la nueva marca.",
"change_password_mail": "Para cambiar su contraseña, haga click en el siguiente enlace:\n",
"login": "acceder",
"notification_from_pictogram": "Notificación desde Pictogram",
"no_name": "Sin nombre",
"no_surname": "Sin apellidos",
"office_link": "El centro/gabinete \"{{ name }}\", con correo electrónico \"{{ email }}\" le ha añadido como parte de su equipo.",
"signin_mail": "Para activar su cuenta en Pictogram, haga click en el siguiente enlace:\n",
"change_password_mail": "Para cambiar su contraseña, haga click en el siguiente enlace:\n",
"login": "acceder",
"student_unlinked": "Se ha desvinculado de {{ name }} {{ surname }}, con número de licencia {{ license }}.",
"therapist_office_request": "El/la terapeuta {{ name }}, con correo electrónico {{ email }}, pide ser asociado a algún estudiante.",
"tutor_office_request": "El/la tutor/a/padre/madre {{ name }}, con correo electrónico {{ email }}, pide ser asociado a algún estudiante.",
"Welcome": "Bienvenido",
"welcome_msg1": "¡Bienvenido a Pictogram, {{ name }}!",
"welcome_msg2": "Su cuenta está ahora activa, por lo que puede",
"office_link": "El centro/gabinete \"{{ name }}\", con correo electrónico \"{{ email }}\" le ha añadido como parte de su equipo."
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment