removing all users from project when it is deleted by creator
This commit is contained in:
parent
c826b06f02
commit
dc41da5007
1 changed files with 15 additions and 5 deletions
|
@ -372,12 +372,22 @@ def deleteProject(token,projectId):
|
|||
if p is None:
|
||||
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.save
|
||||
return accepted("Project deleted")
|
||||
|
||||
return forbidden("user is not owner of Project")
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue