Build out Positions CRUD and rework the Roles page

Positions had list/create/edit already stubbed as list-only; give it real
forms, with a check mirroring the management_position_implies_staff_position
constraint so a bad combination reads as a form error, not a 500. Roles now
groups by role (excluding the MEMBER everyone holds automatically, which was
just noise), grants via a modal instead of a separate page, and its member
picker is a small typeahead combobox instead of a long native <select>.
This commit is contained in:
2026-08-03 18:45:28 +02:00
parent 9b0af5800a
commit ce35348b31
13 changed files with 500 additions and 82 deletions

View File

@@ -7,7 +7,7 @@ from django.utils.translation import gettext_lazy as _
from club.models import ClubMembership, ClubRole, FeePayment
from members.models import Family, FamilyMembership, Member
from members.services.family import find_member_by_email
from teams.models import Team
from teams.models import Position, Team
User = get_user_model()
@@ -25,6 +25,20 @@ class TeamForm(forms.ModelForm):
fields = ["name", "short_name"]
class PositionForm(forms.ModelForm):
class Meta:
model = Position
fields = ["name", "short_name", "ordering", "staff_position", "management_position"]
def clean(self):
cleaned = super().clean()
# Mirrors Position's management_position_implies_staff_position check
# constraint -- caught here so it reads as a form error, not a 500.
if cleaned.get("management_position") and not cleaned.get("staff_position"):
self.add_error("management_position", _("A management position must also be a staff position."))
return cleaned
class ClubRoleAssignForm(forms.ModelForm):
"""Grant a club-wide role to a member already affiliated with this club."""