Пример #1
0
    def delete(self, team_unid, user_unid):
        team = get_team(team_unid)

        user = get_user(user_unid)

        user_team = UserTeam.get_user_team_by_user_and_team(user_unid, team_unid)

        if not user_team:
            return {'status': 'false', 'message': 'The given user is not on that team'}, 400
        
        is_captain = user_team.member_type == 2
        user_team.delete(soft=False)
        new_captain = None
        team.number_participants -= 1

        if is_captain:
            new_captain = UserTeam.get_oldest_team_member(team_unid)

        if new_captain:
            new_captain.member_type = 2
            team.team_captain = new_captain.unid

        return {}, 204