From a1a2d4fc850bb317e467e3417e9f05769c6fee7e Mon Sep 17 00:00:00 2001 From: Noor Date: Sat, 28 Nov 2020 15:31:29 -0800 Subject: [PATCH 1/3] --lead will make the lead a maintainer --- app/controller/command/commands/team.py | 4 ++-- interface/github.py | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/controller/command/commands/team.py b/app/controller/command/commands/team.py index 6bb447e4..8e9abb66 100644 --- a/app/controller/command/commands/team.py +++ b/app/controller/command/commands/team.py @@ -370,12 +370,12 @@ def create_helper(self, param_list, user_id) -> ResponseTuple: self.gh.add_team_member(command_user.github_username, team_id) team.add_member(command_user.github_id) if param_list["lead"] is not None: - msg += "added lead" + msg += "added lead as a maintainer" lead_user = self.facade.retrieve(User, param_list["lead"]) team.add_team_lead(lead_user.github_id) if not self.gh.has_team_member(lead_user.github_username, team_id): - self.gh.add_team_member(lead_user.github_username, team_id) + self.gh.add_team_maintainer(lead_user.github_username, team_id) else: team.add_team_lead(command_user.github_id) diff --git a/interface/github.py b/interface/github.py index a2d0ae2e..9e9a6024 100644 --- a/interface/github.py +++ b/interface/github.py @@ -206,3 +206,9 @@ def remove_team_member(self, username: str, team_id: str): team = self.org.get_team(int(team_id)) to_be_removed_member = cast(NamedUser, self.github.get_user(username)) team.remove_membership(to_be_removed_member) + + @handle_github_error + def add_team_maintainer(self, username: str, team_id: str): + """Add maintainer with given username to team with id team_id.""" + team = self.org.get_team(int(team_id)) + team.add_membership(username, 'maintainer') From 00b0187e09322c01d01b78b820907d7a598bcf1f Mon Sep 17 00:00:00 2001 From: Noor Date: Sat, 28 Nov 2020 15:40:12 -0800 Subject: [PATCH 2/3] fix lint --- app/controller/command/commands/team.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controller/command/commands/team.py b/app/controller/command/commands/team.py index 8e9abb66..c4f8c5be 100644 --- a/app/controller/command/commands/team.py +++ b/app/controller/command/commands/team.py @@ -375,7 +375,8 @@ def create_helper(self, param_list, user_id) -> ResponseTuple: team.add_team_lead(lead_user.github_id) if not self.gh.has_team_member(lead_user.github_username, team_id): - self.gh.add_team_maintainer(lead_user.github_username, team_id) + self.gh.add_team_maintainer( + lead_user.github_username, team_id) else: team.add_team_lead(command_user.github_id) From 142d379c98e9c6744e5f691be8c0773b1af39c61 Mon Sep 17 00:00:00 2001 From: Noor Date: Sat, 28 Nov 2020 16:48:27 -0800 Subject: [PATCH 3/3] cast username to NamedUser --- interface/github.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/interface/github.py b/interface/github.py index 9e9a6024..7c0ffada 100644 --- a/interface/github.py +++ b/interface/github.py @@ -211,4 +211,5 @@ def remove_team_member(self, username: str, team_id: str): def add_team_maintainer(self, username: str, team_id: str): """Add maintainer with given username to team with id team_id.""" team = self.org.get_team(int(team_id)) - team.add_membership(username, 'maintainer') + to_be_maintainer = cast(NamedUser, self.github.get_user(username)) + team.add_membership(to_be_maintainer, 'maintainer')