diff --git a/backend/api/teams/resources.py b/backend/api/teams/resources.py index 3f5c13b848..06df030d27 100644 --- a/backend/api/teams/resources.py +++ b/backend/api/teams/resources.py @@ -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): diff --git a/backend/services/team_service.py b/backend/services/team_service.py index 292360e3b8..508582c63f 100644 --- a/backend/services/team_service.py +++ b/backend/services/team_service.py @@ -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 a team, unlink any associated projects." + }, 400 @staticmethod def check_team_membership(project_id: int, allowed_roles: list, user_id: int):