Add messaging when trying to create a team that already exists

Fixes https://jira.coreos.com/browse/QUAY-827
This commit is contained in:
Joseph Schorr 2018-02-15 16:03:09 -05:00
parent 33b7ca0eaa
commit 72ca758c88
4 changed files with 16 additions and 4 deletions

View file

@ -68,7 +68,7 @@ def handle_addinvite_team(inviter, team, user=None, email=None):
orgname, team.name, inviter.username, invite.invite_token)
return invite
def team_view(orgname, team):
def team_view(orgname, team, is_new_team=False):
view_permission = ViewTeamPermission(orgname, team.name)
role = model.team.get_team_org_role(team).name
return {
@ -76,7 +76,8 @@ def team_view(orgname, team):
'description': team.description,
'can_view': view_permission.can(),
'role': role,
'avatar': avatar.get_data_for_team(team)
'avatar': avatar.get_data_for_team(team),
'new_team': is_new_team,
}
def member_view(member, invited=False):
@ -192,7 +193,7 @@ class OrganizationTeam(ApiResource):
get_authenticated_user().username)
log_action('org_set_team_role', orgname, {'team': teamname, 'role': details['role']})
return team_view(orgname, team), 200
return team_view(orgname, team, is_new_team=not is_existing), 200
raise Unauthorized()