Skip to content

Let team managers delete a team #914

Todo

Description

@TinyMarsh

Description and motivation

Team managers cannot delete a team. Only an admin can do it, through the Django admin. #569 says managers should be able to delete their teams, and Adrian raised this again in the review of #906 (team creation for #705).

Proposed approach

Managers already get the delete_team object permission through their membership, so the permission check is in place. What is missing:

  • A delete_team() function in main/team_services.py that checks the person is a manager and deletes the team. When a team is deleted, its memberships are deleted with it, and the existing pre_delete signal on Team removes its Guardian permissions.
  • A view at teams/<slug>/delete/ that shows a confirmation page on GET and deletes on POST. It requires the delete_team object permission, and returns a 404 to anyone else.
  • A Delete team button (btn-danger) at the bottom of the team page, shown only to managers.
  • After deleting, redirect to My Teams with a success message.

Questions to settle before building:

  • Is a simple "Are you sure?" page enough, or should the manager type the team name to confirm?
  • Should any manager be able to delete the team, or only when they are the sole manager?

Acceptance criteria

  • A manager can delete a team after confirming, and is redirected to My Teams.
  • The team, its memberships and its Guardian permissions are all removed.
  • Existing invitation links for the deleted team show the invalid link page.
  • Regular members do not see the button, and GET or POST to the view returns a 404 for them.
  • People outside the team get a 404.
  • Service and view tests follow docs/dev-guide/testing.md.

Affected areas

Services (main/team_services.py), views, URLs, team page template, new confirmation template, tests, docs/dev-guide/architecture.md.

Additional context

Deleting a team cannot be undone, so the confirmation step matters.

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