Fill in the remove team methods.
This commit is contained in:
parent
d2601c6fe4
commit
427ffea6b7
2 changed files with 15 additions and 7 deletions
|
@ -112,9 +112,17 @@ def create_team(name, org, team_role_name, description=''):
|
||||||
description=description)
|
description=description)
|
||||||
|
|
||||||
|
|
||||||
def remove_team(name, org):
|
def remove_team(org_name, team_name):
|
||||||
# TODO: have code to remove the team, and all its repo permissions, etc.
|
found = list(Team.select().join(User).where(User.organization == True,
|
||||||
pass
|
User.username == org_name,
|
||||||
|
Team.name == team_name))
|
||||||
|
if not found:
|
||||||
|
raise InvalidTeamException('Team named: %s is not a team in org: %s' %
|
||||||
|
(team_name, org_name))
|
||||||
|
|
||||||
|
team = found[0]
|
||||||
|
team.delete_instance(recursive=True, delete_nullable=True)
|
||||||
|
|
||||||
|
|
||||||
def add_user_to_team(user, team):
|
def add_user_to_team(user, team):
|
||||||
return TeamMember.create(user=user, team=team)
|
return TeamMember.create(user=user, team=team)
|
||||||
|
@ -207,7 +215,7 @@ def validate_reset_code(code):
|
||||||
|
|
||||||
def get_user(username):
|
def get_user(username):
|
||||||
try:
|
try:
|
||||||
return User.get(User.username == username)
|
return User.get(User.username == username, User.organization == False)
|
||||||
except User.DoesNotExist:
|
except User.DoesNotExist:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
|
@ -346,9 +346,9 @@ def update_organization_team(orgname, teamname):
|
||||||
@app.route('/api/organization/<orgname>/team/<teamname>',
|
@app.route('/api/organization/<orgname>/team/<teamname>',
|
||||||
methods=['DELETE'])
|
methods=['DELETE'])
|
||||||
def delete_organization_team(orgname, teamname):
|
def delete_organization_team(orgname, teamname):
|
||||||
edit_permission = AdministerOrganizationPermission(orgname)
|
permission = AdministerOrganizationPermission(orgname)
|
||||||
if edit_permission.can():
|
if permission.can():
|
||||||
model.remove_team(teamname, orgname)
|
model.remove_team(orgname, teamname)
|
||||||
return make_response('Deleted', 204)
|
return make_response('Deleted', 204)
|
||||||
|
|
||||||
abort(403)
|
abort(403)
|
||||||
|
|
Reference in a new issue