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

feat: grant team lead maintainer permissions on team create #595

Merged
merged 3 commits into from
Nov 29, 2020
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
5 changes: 3 additions & 2 deletions app/controller/command/commands/team.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,12 +370,13 @@ 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)

Expand Down
7 changes: 7 additions & 0 deletions interface/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,3 +206,10 @@ 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))
to_be_maintainer = cast(NamedUser, self.github.get_user(username))
team.add_membership(to_be_maintainer, 'maintainer')