From 5706e9064ebffe9f0e1d4e8eb72644524ecaa355 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Kervella?= Date: Sun, 29 Apr 2018 14:37:18 +0000 Subject: [PATCH] Fix #117 : Use unix_name instead of name for ldap groups A group in the LDAP now use the `unix_name` instead of the `name` The `new_group` form has now a more logical order for the fields The label for the `unix_name` is now more explicit --- users/forms.py | 13 +++++++------ users/models.py | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/users/forms.py b/users/forms.py index 8c6f5db9..670fbb98 100644 --- a/users/forms.py +++ b/users/forms.py @@ -501,7 +501,7 @@ class ShellForm(FormRevMixin, ModelForm): class ListRightForm(FormRevMixin, ModelForm): """Edition, d'un groupe , équivalent à un droit - Ne peremet pas d'editer le gid, car il sert de primary key""" + Ne permet pas d'editer le gid, car il sert de primary key""" permissions = forms.ModelMultipleChoiceField( Permission.objects.all().select_related('content_type'), widget=forms.CheckboxSelectMultiple, @@ -510,23 +510,24 @@ class ListRightForm(FormRevMixin, ModelForm): class Meta: model = ListRight - fields = ['name', 'unix_name', 'critical', 'permissions', 'details'] + fields = ('name', 'unix_name', 'critical', 'permissions', 'details') def __init__(self, *args, **kwargs): prefix = kwargs.pop('prefix', self.Meta.model.__name__) super(ListRightForm, self).__init__(*args, prefix=prefix, **kwargs) - self.fields['unix_name'].label = 'Nom du droit/groupe' + self.fields['unix_name'].label = 'Nom UNIX du groupe' class NewListRightForm(ListRightForm): """Ajout d'un groupe/list de droit """ class Meta(ListRightForm.Meta): - fields = '__all__' + fields = ('name', 'unix_name', 'gid', 'critical', 'permissions', + 'details') def __init__(self, *args, **kwargs): super(NewListRightForm, self).__init__(*args, **kwargs) - self.fields['gid'].label = 'Gid, attention, cet attribut ne doit\ - pas être modifié après création' + self.fields['gid'].label = ("Gid, attention, cet attribut ne doit " + "pas être modifié après création") class DelListRightForm(Form): diff --git a/users/models.py b/users/models.py index d0e21997..0284985c 100644 --- a/users/models.py +++ b/users/models.py @@ -1175,7 +1175,7 @@ class ListRight(RevMixin, AclMixin, Group): group_ldap = LdapUserGroup.objects.get(gid=self.gid) except LdapUserGroup.DoesNotExist: group_ldap = LdapUserGroup(gid=self.gid) - group_ldap.name = self.listright + group_ldap.name = self.unix_name group_ldap.members = [user.pseudo for user in self.user_set.all()] group_ldap.save()