mirror of
https://github.com/ae-utbm/sith.git
synced 2026-09-01 18:19:21 +00:00
Show linked groups on club role form page
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -49,6 +49,20 @@
|
||||
{{ subform.is_active.help_text }}
|
||||
</span>
|
||||
</div>
|
||||
{% set groups = subform.instance.linked_groups.all()|list %}
|
||||
{% if groups %}
|
||||
<div>
|
||||
<p>
|
||||
<strong>{% trans %}Linked groups : {% endtrans %}</strong>
|
||||
{{ groups|map(attribute="name")|join(", ") }}
|
||||
</p>
|
||||
<p class="helptext">
|
||||
{% trans trimmed %}
|
||||
Users receiving this role will also be assigned to those groups
|
||||
{% endtrans %}
|
||||
</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</details>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user