Add edit/delete actions to the teams list

Admin-only, matching TeamCreateView/TeamUpdateView's existing gate.
Deleting cascades away the team's roster and staff assignments -- no
ProtectedError to catch, unlike a Member that orders/invoices can still
reference. Edit links to the detail page rather than the edit form
directly, same convention as the news and member lists.
This commit is contained in:
2026-08-03 21:42:23 +02:00
parent 2261f86596
commit 9a2a06180f
5 changed files with 67 additions and 2 deletions

View File

@@ -713,6 +713,19 @@ class TeamUpdateView(ClubAdminRequiredMixin, UpdateView):
return super().get_context_data(update_view=True, **kwargs)
class TeamDeleteView(ClubAdminRequiredMixin, View):
def post(self, request, pk):
team = get_object_or_404(Team.objects.filter(club=request.club), pk=pk)
name = str(team)
# TeamMembership/StaffAssignment cascade away with the team -- no ProtectedError
# to catch, unlike a Member (which orders/invoices can still reference).
team.delete()
body = _("%(team)s” has been deleted.") % {"team": name}
notify(request, f"w|{_('Team deleted')}|{body}")
return redirect("management:team_list")
class TeamDetailView(ClubStaffRequiredMixin, DetailView):
template_name = "management/team_detail.html"
context_object_name = "team"