refactorized default method string

parent 55bd53a0
......@@ -139,15 +139,6 @@ module.exports = {
if (!student)
throw new Error("student not found");
student.current_method = student.lastInstruction[0] ? student.lastInstruction[0].met_name : "no_method";
student.current_instruction = student.lastInstruction[0] ? student.lastInstruction[0].ins_name : "no_instruction";
// determine supervision level of the requester on the student
var stu_sup = StuSup.findOne({id_stu: student.id, id_sup: req.token.id});
return [student, stu_sup];
})
.spread(function (student, stu_sup) {
// Promisify asynchronous call to Student.supervisors
var supervisors = new Promise(function (resolve, reject) {
Student.validSupervisors(student.id, req.token.id, function (err, ss) {
......
......@@ -116,6 +116,8 @@ module.exports = {
student.license.isOfficial = student.license.type == 'official';
}
student.attributes = Student.getValidAttributes(student.attributes);
student.current_method = student.lastInstruction[0] ? student.lastInstruction[0].met_name : "no_method";
student.current_instruction = student.lastInstruction[0] ? student.lastInstruction[0].ins_name : "no_instruction";
delete student.password;
return student;
},
......
......@@ -126,6 +126,11 @@ module.exports = {
toJSON: function () {
var supervisor = this.toObject();
supervisor.pic = sails.config.pictogram.urls.getSupervisorAvatarUrl(supervisor.pic);
supervisor.isTutor = supervisor.role == 'tutor';
supervisor.isTherapist = supervisor.role == 'therapist';
supervisor.isOffice = supervisor.role == 'office';
supervisor.isAdmin = supervisor.role == 'admin';
delete supervisor.password;
return supervisor;
},
......@@ -249,8 +254,6 @@ module.exports = {
return next_cb();
s = s.toJSON();
s.current_method = s.lastInstruction[0] ? s.lastInstruction[0].met_name : "no_method";
s.current_instruction = s.lastInstruction[0] ? s.lastInstruction[0].ins_name : "no_instruction";
if (!s.license)
return next_cb();
l.push(s);
......@@ -295,8 +298,6 @@ module.exports = {
return next_cb();
s = s.toJSON();
s.current_method = s.lastInstruction[0] ? s.lastInstruction[0].met_name : "no_method";
s.current_instruction = s.lastInstruction[0] ? s.lastInstruction[0].ins_name : "no_instruction";
if (!s.license)
return next_cb();
l.push(s);
......
......@@ -67,12 +67,6 @@ function LoginCtrl(
// Adapt language en-us to en-gb (the latter is the one supported for 'en')
if (data.user.lang === 'en-us')
data.user.lang = 'en-gb';
data.user.isTutor = data.user.role == 'tutor';
data.user.isTherapist = data.user.role == 'therapist';
data.user.isOffice = data.user.role == 'office';
data.user.isAdmin = data.user.role == 'admin';
$scope.lang = data.user.lang;
$translate.use($scope.lang);
} else {
......
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