Skip to content

Let members leave a team #913

Todo
Todo

Description

@TinyMarsh

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 calls leave_team() on POST. It requires the view_team object 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.

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