diff --git a/users/forms.py b/users/forms.py
index 31331051..ac8e9923 100644
--- a/users/forms.py
+++ b/users/forms.py
@@ -38,6 +38,7 @@ from django.forms import ModelForm, Form
from django.contrib.auth.forms import ReadOnlyPasswordHashField
from django.core.validators import MinLengthValidator
from django.utils import timezone
+from django.contrib.auth.models import Group, Permission
from preferences.models import OptionalUser
from .models import User, ServiceUser, School, ListRight, Whitelist
@@ -409,6 +410,23 @@ class StateForm(ModelForm):
super(StateForm, self).__init__(*args, prefix=prefix, **kwargs)
+class GroupForm(ModelForm):
+ """ Gestion des groupes d'un user"""
+ groups = forms.ModelMultipleChoiceField(
+ Group.objects.all(),
+ widget=forms.CheckboxSelectMultiple,
+ required=False
+ )
+
+ class Meta:
+ model = User
+ fields = ['groups']
+
+ def __init__(self, *args, **kwargs):
+ prefix = kwargs.pop('prefix', self.Meta.model.__name__)
+ super(GroupForm, self).__init__(*args, prefix=prefix, **kwargs)
+
+
class SchoolForm(ModelForm):
"""Edition, creation d'un école"""
class Meta:
@@ -424,6 +442,12 @@ class SchoolForm(ModelForm):
class ListRightForm(ModelForm):
"""Edition, d'un groupe , équivalent à un droit
Ne peremet pas d'editer le gid, car il sert de primary key"""
+ permissions = forms.ModelMultipleChoiceField(
+ Permission.objects.all(),
+ widget=forms.CheckboxSelectMultiple,
+ required=False
+ )
+
class Meta:
model = ListRight
fields = ['name', 'unix_name', 'permissions', 'details']
@@ -457,9 +481,9 @@ class DelListRightForm(Form):
instances = kwargs.pop('instances', None)
super(DelListRightForm, self).__init__(*args, **kwargs)
if instances:
- self.fields['unix_name'].queryset = instances
+ self.fields['listrights'].queryset = instances
else:
- self.fields['unix_name'].queryset = ListRight.objects.all()
+ self.fields['listrights'].queryset = ListRight.objects.all()
class DelSchoolForm(Form):
diff --git a/users/models.py b/users/models.py
index 254c6a26..d3f947b1 100644
--- a/users/models.py
+++ b/users/models.py
@@ -1153,8 +1153,8 @@ class ListRight(Group):
except LdapUserGroup.DoesNotExist:
group_ldap = LdapUserGroup(gid=self.gid)
group_ldap.name = self.listright
- group_ldap.members = [right.user.pseudo for right
- in Right.objects.filter(right=self)]
+ group_ldap.members = [user.pseudo for user
+ in self.user_set.all()]
group_ldap.save()
def ldap_del(self):
diff --git a/users/templates/users/aff_listright.html b/users/templates/users/aff_listright.html
index 2ca41e09..207d07bb 100644
--- a/users/templates/users/aff_listright.html
+++ b/users/templates/users/aff_listright.html
@@ -38,8 +38,20 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{{ listright.name }}
{{ listright.gid }}
-
{{ listright.permissions.all }}
-
{{ listright.user_set.all }}
+
+
+
+
+ {% for perm in listright.permissions.all %}
+
+ {{ perm.name }}
+
+ {% endfor %}
+
+
+
{% for user in listright.user_set.all %}{{user}} | {% endfor %}
{{ listright.details }}
{% include 'buttons/edit.html' with href='users:edit-listright' id=listright.id %}
diff --git a/users/templates/users/profil.html b/users/templates/users/profil.html
index 70a0fec8..27d699ac 100644
--- a/users/templates/users/profil.html
+++ b/users/templates/users/profil.html
@@ -42,7 +42,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
Changer le statut
-
+
+
+ Gérer les groupes
+
+
Historique
@@ -117,9 +121,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% else %}
Désactivé
{% endif %}
-
Droits
- {% if list_droits %}
-
{% for droit in list_droits %}{{ droit.right }}{% if list_droits|length != forloop.counter %} - {% endif %} {% endfor %}