Group: add a label on users to delete

This commit is contained in:
Antoine Bartuccio 2019-04-10 14:11:31 +02:00
parent 08d03087a4
commit b693ee32f2
Signed by: klmp200
GPG Key ID: E7245548C53F904B
2 changed files with 5 additions and 1 deletions

View File

@ -12,6 +12,7 @@
{% else %} {% else %}
<form action="{{ url('core:group_detail', object.id) }}" method="post" id="add_users"> <form action="{{ url('core:group_detail', object.id) }}" method="post" id="add_users">
{% csrf_token %} {% csrf_token %}
<label for="{{ form.users_removed.id_for_label }}">{{ form.users_removed.label }} :</label>
{{ form.users_removed.errors }} {{ form.users_removed.errors }}
{% for user in form.users_removed %} {% for user in form.users_removed %}
<label for="{{ user.id_for_label }}"> <label for="{{ user.id_for_label }}">

View File

@ -52,7 +52,7 @@ class EditMembersForm(forms.Form):
super(EditMembersForm, self).__init__(*args, **kwargs) super(EditMembersForm, self).__init__(*args, **kwargs)
self.fields["users_removed"] = forms.ModelMultipleChoiceField( self.fields["users_removed"] = forms.ModelMultipleChoiceField(
User.objects.filter(id__in=self.current_users).all(), User.objects.filter(id__in=self.current_users).all(),
label=None, label=_("Users to delete"),
required=False, required=False,
widget=forms.CheckboxSelectMultiple, widget=forms.CheckboxSelectMultiple,
) )
@ -65,6 +65,9 @@ class EditMembersForm(forms.Form):
) )
def clean_users_added(self): def clean_users_added(self):
"""
Check that the user is not trying to add an user already in the group
"""
cleaned_data = super(EditMembersForm, self).clean() cleaned_data = super(EditMembersForm, self).clean()
users_added = cleaned_data.get("users_added", None) users_added = cleaned_data.get("users_added", None)
if not users_added: if not users_added: