Fix removing members from classrooms and course instances

This commit is contained in:
Scott Erickson 2015-12-02 13:59:47 -08:00
parent 3c1a55fc2f
commit 4403347290
2 changed files with 2 additions and 2 deletions

View file

@ -79,7 +79,7 @@ ClassroomHandler = class ClassroomHandler extends Handler
alreadyNotInClassroom = not _.any classroom.get('members') or [], (memberID) -> memberID.toString() is userID
return @sendSuccess(res, @formatEntity(req, classroom)) if alreadyNotInClassroom
members = _.clone(classroom.get('members'))
members.splice(members.indexOf(userID), 1)
members = (m for m in members when m.toString() isnt userID)
classroom.set('members', members)
classroom.save (err, classroom) =>
return @sendDatabaseError(res, err) if err

View file

@ -111,7 +111,7 @@ CourseInstanceHandler = class CourseInstanceHandler extends Handler
alreadyNotInCourseInstance = not _.any courseInstance.get('members') or [], (memberID) -> memberID.toString() is userID
return @sendSuccess(res, @formatEntity(req, courseInstance)) if alreadyNotInCourseInstance
members = _.clone(courseInstance.get('members'))
members.splice(members.indexOf(userID), 1)
members = (m for m in members when m.toString() isnt userID)
courseInstance.set('members', members)
courseInstance.save (err, courseInstance) =>
return @sendDatabaseError(res, err) if err