diff --git a/club/forms.py b/club/forms.py index 2f9db670..80d4c058 100644 --- a/club/forms.py +++ b/club/forms.py @@ -479,6 +479,13 @@ class ClubRoleCreateForm(forms.ModelForm): class ClubRoleBaseFormSet(forms.BaseInlineFormSet): ordering_widget = forms.HiddenInput() + def __init__(self, *args, queryset=None, **kwargs): + if queryset is None: + queryset = self.model._default_manager + super().__init__( + *args, queryset=queryset.prefetch_related("linked_groups"), **kwargs + ) + ClubRoleFormSet = forms.inlineformset_factory( Club, diff --git a/club/templates/club/club_roles.jinja b/club/templates/club/club_roles.jinja index ddc54b0c..bb860f10 100644 --- a/club/templates/club/club_roles.jinja +++ b/club/templates/club/club_roles.jinja @@ -49,6 +49,20 @@ {{ subform.is_active.help_text }} + {% set groups = subform.instance.linked_groups.all()|list %} + {% if groups %} +
+ {% trans %}Linked groups : {% endtrans %} + {{ groups|map(attribute="name")|join(", ") }} +
++ {% trans trimmed %} + Users receiving this role will also be assigned to those groups + {% endtrans %} +
+