diff --git a/wtnt/user/profile/service.py b/wtnt/user/profile/service.py index 7b90a78..b373a40 100644 --- a/wtnt/user/profile/service.py +++ b/wtnt/user/profile/service.py @@ -251,11 +251,29 @@ def get_my_team_detail(self): return data + def finish_project(self): + team_id = self.kwargs.get("team_id") + user_id = self.request.user.id + try: + team = Team.objects.select_related("leader").get(id=team_id) + except Team.DoesNotExist: + raise notfound_exception.TeamNotFoundError() + + self.check_leader(user_id, team.leader.id) + + team.is_accomplished = True + team.save() + + return {"detail": f"{team.title} is accomplished."} + def ban_user_from_team(self): team_id = self.kwargs.get("team_id") user_id = self.request.user.id - team = Team.objects.select_related("leader").get(id=team_id) + try: + team = Team.objects.select_related("leader").get(id=team_id) + except Team.DoesNotExist: + raise notfound_exception.TeamNotFoundError() self.check_leader(user_id, team.leader.id)