Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HotFix - 어드민/팀의 승인/관리 디테일 API의 응답 수정 #71

Merged
merged 3 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions wtnt/admin/team/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,12 @@ def detailed_team(self):
except Team.DoesNotExist:
raise notfound_exception.TeamNotFoundError()

member_ids = TeamUser.objects.filter(team_id=team_id).values_list("user_id", flat=True)
members = User.objects.filter(id__in=member_ids)
member_id_tech = TeamUser.objects.filter(team_id=team_id).values_list("user_id", "tech")
member_id_tech_dict = {user_id: tech for user_id, tech in member_id_tech}

members = User.objects.filter(id__in=member_id_tech_dict.keys())
serializer = AdminTeamManageDetailSerializer(members, many=True)

data = TeamResponse.make_team_manage_detail_data(serializer.data, team)
data = TeamResponse.make_team_manage_detail_data(serializer.data, team, member_id_tech_dict)

return data
4 changes: 3 additions & 1 deletion wtnt/core/utils/admin.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
class TeamResponse:
@staticmethod
def make_team_manage_detail_data(members, team):
def make_team_manage_detail_data(members, team, _dict):
leader_id = team.leader.id

for i, member in enumerate(members):
if member["id"] == leader_id:
leader_info = members.pop(i)
leader_info["category"] = _dict[leader_info["id"]]
break
member["category"] = _dict[member["id"]]

return {
"title": team.title,
Expand Down
4 changes: 3 additions & 1 deletion wtnt/core/utils/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ def make_activity_data(teams, user_id, owner_id):
return {"team": teams, "is_owner": user_id == owner_id}

@staticmethod
def make_team_manage_detail_data(members, team):
def make_team_manage_detail_data(members, team, _dict):
leader_id = team.leader.id

for i, member in enumerate(members):
if member["id"] == leader_id:
leader_info = members.pop(i)
leader_info["category"] = _dict[leader_info["id"]]
break
member["category"] = _dict[member["id"]]

return {
"title": team.title,
Expand Down
9 changes: 5 additions & 4 deletions wtnt/user/profile/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,11 @@ def get_my_team_detail(self):
except Team.DoesNotExist:
raise notfound_exception.TeamNotFoundError()

member_ids = TeamUser.objects.filter(team_id=team_id).values_list("user_id", flat=True)
members = User.objects.filter(id__in=member_ids)
serializer = UserSerializerOnTeamManageDetail(members, many=True)
member_id_tech = TeamUser.objects.filter(team_id=team_id).values_list("user_id", "tech")
member_id_tech_dict = {user_id: tech for user_id, tech in member_id_tech}

data = ProfileResponse.make_team_manage_detail_data(serializer.data, team)
members = User.objects.filter(id__in=member_id_tech_dict.keys())
serializer = UserSerializerOnTeamManageDetail(members, many=True)
data = ProfileResponse.make_team_manage_detail_data(serializer.data, team, member_id_tech_dict)

return data