removing all users from project when it is deleted by creator

This commit is contained in:
Aran Zaiger 2015-08-02 12:35:06 +03:00
parent c826b06f02
commit dc41da5007

View file

@ -372,12 +372,22 @@ def deleteProject(token,projectId):
if p is None: if p is None:
return bad_request("no such Project") return bad_request("no such Project")
if p.master_id == user.key().id(): if p.master_id != user.key().id():
return forbidden("user is not owner of Project")
#remove all users related to project
for uId in p.membersId:
user = User.get_by_id(uId)
if user is None:
return bad_request("trying to remove a user from project failed")
user.projects_id_list.remove(p.key().id())
db.put(user)
db.delete(p) db.delete(p)
db.save db.save
return accepted("Project deleted") return accepted("Project deleted")
return forbidden("user is not owner of Project")