diff --git a/club/forms.py b/club/forms.py index a18851a0..b41f9aef 100644 --- a/club/forms.py +++ b/club/forms.py @@ -250,19 +250,20 @@ class ClubAddMemberForm(ClubMemberForm): widgets = {"user": AutoCompleteSelectUser} @cached_property - def available_roles(self): - """The greatest role that will be obtainable with this form. + def available_roles(self) -> QuerySet[ClubRole]: + """The roles that will be obtainable with this form. Admins and the club president can attribute any role. Board members can attribute roles lower than their own. Other users cannot attribute roles with this form """ - if self.request_user.has_perm("club.add_membership"): - return self.club.roles.all() membership = self.request_user_membership if membership is None or not membership.role.is_board: return ClubRole.objects.none() - if membership.role.is_presidency: + if ( + self.request_user.has_perm("club.add_membership") + or membership.role.is_presidency + ): return self.club.roles.all() return self.club.roles.above_instance(membership.role)