Skip to content

Commit

Permalink
Merge pull request #6142 from hotosm/fix/team-delete-message-for-asso…
Browse files Browse the repository at this point in the history
…ciated-projects

fix: team delete message for associated projects
  • Loading branch information
ramyaragupathy authored Nov 27, 2023
2 parents 8b3ccc2 + 1965f37 commit 3e43f21
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 1 addition & 2 deletions backend/api/teams/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,7 @@ def delete(self, team_id):
"SubCode": "UserNotTeamManager",
}, 401

TeamService.delete_team(team_id)
return {"Success": "Team deleted"}, 200
return TeamService.delete_team(team_id)


class TeamsAllAPI(Resource):
Expand Down
6 changes: 5 additions & 1 deletion backend/services/team_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,8 +566,12 @@ def delete_team(team_id: int):

if team.can_be_deleted():
team.delete()
return {"Success": "Team deleted"}, 200
else:
raise TeamServiceError("Team has projects, cannot be deleted")
return {
"Error": "Team has projects, cannot be deleted",
"SubCode": "This team has projects associated. Before deleting team, unlink any associated projects.",
}, 400

@staticmethod
def check_team_membership(project_id: int, allowed_roles: list, user_id: int):
Expand Down

0 comments on commit 3e43f21

Please sign in to comment.