Skip to content

Let team managers promote and demote members #912

Todo

Description

@TinyMarsh

Description and motivation

A team can have more than one manager, but at the moment the only way to make someone a manager, or to stop them being one, is through the Django admin. Team managers should be able to do this themselves from the team page.

This came up in the review of #906 (team creation for #705).

Proposed approach

The service function already exists: change_member_role() in main/team_services.py checks that the person making the change is a manager, and the TeamMembership model refuses any change that would leave a team with no managers. Guardian permissions are updated automatically when a membership is saved. So this is mostly view and template work:

  • Add a POST-only view that calls change_member_role(), protected by the manage_team_members object permission (the same check as the invitation link page).
  • On the team page, show managers a Make manager or Remove manager role button on each roster row. Regular members do not see these buttons.
  • If the change is refused (for example, demoting the last manager), show the error message on the team page instead of a server error.

Questions to settle before building:

  • Can a manager remove their own manager role, as long as another manager remains? (The model allows it.)
  • Should we ask for confirmation before removing someone's manager role?

Acceptance criteria

  • A manager can promote a regular member to manager from the team page.
  • A manager can demote another manager to regular member from the team page.
  • Demoting the last manager is refused with a clear message, and the team keeps its manager.
  • Regular members do not see the role buttons, and posting to the view directly returns a 404.
  • People outside the team get a 404.
  • View tests follow docs/dev-guide/testing.md.

Affected areas

Views (main/views/team_views.py), URLs, team page template, tables (TeamMembershipTable), tests, docs/dev-guide/architecture.md.

Additional context

remove_member() in the same module also has no UI yet. It could sit next to the role buttons, either in this issue or a separate one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

feature

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions