Repository navigation
Description
Description and motivation
Team members have no way to leave a team. Once someone accepts an invitation, only an admin can remove them. Members should be able to leave a team themselves from the team page.
This came up in the review of #906 (team creation for #705).
Proposed approach
The service function already exists: leave_team() in main/team_services.py deletes the person's own membership. The TeamMembership model refuses to delete the last manager, and Guardian permissions are removed automatically when a membership is deleted. So this is mostly view and template work:
- Add a view at
teams/<slug>/leave/that shows a confirmation page on GET and callsleave_team()on POST. It requires theview_teamobject permission (that is, the person must be a member). - Add a Leave team button (
btn-danger) at the bottom of the team page, as Adrian suggested. - After leaving, redirect to My Teams with a success message.
- If the person is the last manager, refuse and explain that they must make someone else a manager first (see the promote and demote issue), or delete the team.
Acceptance criteria
- A member can leave a team after confirming, and is redirected to My Teams.
- After leaving, the team no longer appears in My Teams and its page returns a 404 for them.
- A manager who is not the last manager can leave.
- The last manager is refused with a clear message, and their membership is unchanged.
- 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, new confirmation template, tests, docs/dev-guide/architecture.md.
Additional context
Related: the promote/demote issue, because a sole manager needs a way to hand over the team before leaving.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fields📋 Backlog
Activity