Fix delete team error message for admin teams

This commit is contained in:
Joseph Schorr 2016-07-11 15:47:05 -04:00
parent da0357a460
commit c1e4bf79b7
2 changed files with 10 additions and 7 deletions

View file

@ -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)