Merge pull request #1611 from coreos-inc/team-delete
Fix delete team error message for admin teams
This commit is contained in:
commit
74023ff696
2 changed files with 10 additions and 7 deletions
|
@ -97,12 +97,10 @@ def remove_team(org_name, team_name, removed_by_username):
|
|||
team = found[0]
|
||||
if team.role.name == 'admin':
|
||||
admin_teams = list(__get_user_admin_teams(org_name, removed_by_username))
|
||||
|
||||
if len(admin_teams) <= 1:
|
||||
# The team we are trying to remove is the only admin team for this user
|
||||
msg = ('Deleting team \'%s\' would remove all admin from user \'%s\'' %
|
||||
(team_name, removed_by_username))
|
||||
raise DataModelException(msg)
|
||||
# The team we are trying to remove is the only admin team containing this user.
|
||||
msg = "Deleting team '%s' would remove admin ability for user '%s' in organization '%s'"
|
||||
raise DataModelException(msg % (team_name, removed_by_username, org_name))
|
||||
|
||||
team.delete_instance(recursive=True, delete_nullable=True)
|
||||
|
||||
|
|
|
@ -1146,8 +1146,13 @@ class TestDeleteOrganizationTeam(ApiTestCase):
|
|||
def test_attemptdeleteowners(self):
|
||||
self.login(ADMIN_ACCESS_USER)
|
||||
|
||||
self.deleteResponse(OrganizationTeam, params=dict(orgname=ORGANIZATION, teamname='owners'),
|
||||
expected_code=400)
|
||||
resp = self.deleteResponse(OrganizationTeam,
|
||||
params=dict(orgname=ORGANIZATION, teamname='owners'),
|
||||
expected_code=400)
|
||||
data = py_json.loads(resp)
|
||||
msg = ("Deleting team 'owners' would remove admin ability for user " +
|
||||
"'devtable' in organization 'buynlarge'")
|
||||
self.assertEquals(msg, data['message'])
|
||||
|
||||
|
||||
class TestGetOrganizationTeamMembers(ApiTestCase):
|
||||
|
|
Reference in a new issue