added: when user is removed from course he is also removed from projects inside course #126

This commit is contained in:
Aran Zaiger 2015-08-01 17:17:53 +03:00
parent 4b08085d63
commit ad3b232f5d

View file

@ -646,6 +646,13 @@ def removeUserFromCourse(token, userId, courseId):
except Exception as e:
return bad_request("user is not listed to this course")
#remove user from all projects in course
projects = Project.all().filter("courseId =", course.key().id())
for p in projects:
if p.key().id() in userToRemove.projects_id_list:
userToRemove.projects_id_list.remove(p.key().id())
p.membersId.remove(userToRemove.key().id())
db.put(p)
db.put(userToRemove)