fixing issue with therapist related students

parent a8f28e51
Showing with 9 additions and 2 deletions
...@@ -305,8 +305,15 @@ module.exports = { ...@@ -305,8 +305,15 @@ module.exports = {
}) })
.spread((stuSups, supOffs) => { .spread((stuSups, supOffs) => {
if (!supOffs || supOffs.length == 0) if (!supOffs || supOffs.length == 0) {
throw new Error("No supervisors"); // if we get here, only the requester being directly related to the
// student is valid
var supIdx = stuSups.findIndex(x => x.supervisor.id == id_sup);
if (supIdx >= 0)
return callback(null, [stuSups[supIdx].supervisor]);
throw new Error("No supervisors related");
}
// filter null entries and map them to the supervisor object // filter null entries and map them to the supervisor object
var ss = _.compact(_.compact(stuSups).map(x => x.supervisor)); var ss = _.compact(_.compact(stuSups).map(x => x.supervisor));
......
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