solved a pair of issues

parent 4881eaf6
...@@ -685,7 +685,7 @@ module.exports = { ...@@ -685,7 +685,7 @@ module.exports = {
// Leave all rooms // Leave all rooms
for(var i=0; i<rooms.length; i++){ for(var i=0; i<rooms.length; i++){
sails.sockets.leave(req.socket, rooms[i]); sails.sockets.leave(req.socket, rooms[i]);
sails.log.debug("Unsusbscribe from room " + room[i]); sails.log.debug("Unsusbscribe from room " + rooms[i]);
} }
res.json({ res.json({
......
...@@ -199,6 +199,7 @@ module.exports = { ...@@ -199,6 +199,7 @@ module.exports = {
// First, let's get the list of students of the supervisor // First, let's get the list of students of the supervisor
// //
function (cb) { function (cb) {
console.log("getting supervisor's students");
StuSup.find({supervisor: idSup}).populate('student').exec(function(err, stusups){ StuSup.find({supervisor: idSup}).populate('student').exec(function(err, stusups){
if (err) return cb(err); if (err) return cb(err);
if (stusups) { if (stusups) {
...@@ -224,6 +225,7 @@ module.exports = { ...@@ -224,6 +225,7 @@ module.exports = {
// the list of students // the list of students
// //
function (cb) { function (cb) {
console.log("getting office students");
if (req.token.isSupAdmin) { if (req.token.isSupAdmin) {
Student.find({office: req.token.office.id }).exec(function(err, students){ Student.find({office: req.token.office.id }).exec(function(err, students){
if (err) return cb(err); if (err) return cb(err);
...@@ -231,6 +233,7 @@ module.exports = { ...@@ -231,6 +233,7 @@ module.exports = {
var l_stu_id = _.pluck(l_stu, 'id'); // get a list of supervised student ids var l_stu_id = _.pluck(l_stu, 'id'); // get a list of supervised student ids
if (students) { if (students) {
async.eachSeries(students, function(student, next) { async.eachSeries(students, function(student, next) {
console.log("student " + JSON.stringify(student));
if (_.indexOf(l_stu_id, student.id) == -1) { // a new student, let's add it if (_.indexOf(l_stu_id, student.id) == -1) { // a new student, let's add it
// no supervised // no supervised
student.supervision = 0; student.supervision = 0;
...@@ -244,12 +247,13 @@ module.exports = { ...@@ -244,12 +247,13 @@ module.exports = {
}); });
} else cb(); } else cb();
}); });
} } else cb();
}, },
// //
// Populate students with methods // Populate students with methods
// //
function (cb) { function (cb) {
console.log("assigning methods");
async.eachSeries(l_stu, function(student, next) { async.eachSeries(l_stu, function(student, next) {
VStuLastInstruction.findOne(student.id).exec(function(err, row) { VStuLastInstruction.findOne(student.id).exec(function(err, row) {
if (err) { if (err) {
...@@ -274,7 +278,8 @@ module.exports = { ...@@ -274,7 +278,8 @@ module.exports = {
} }
], ],
function(err) { // All steps done! return list of students if no error function(err) { // All steps done! return list of students if no error
if (err) return json(500, {err: err}); console.log("done!");
if (err) return res.json(500, {err: err});
return res.json(l_stu); return res.json(l_stu);
} }
); );
......
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