8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-26 06:32:26 +00:00

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
This commit is contained in:
Maël Kervella 2018-04-29 14:37:18 +00:00
parent 40247e326d
commit 5706e9064e
2 changed files with 8 additions and 7 deletions

View file

@ -501,7 +501,7 @@ class ShellForm(FormRevMixin, ModelForm):
class ListRightForm(FormRevMixin, ModelForm): class ListRightForm(FormRevMixin, ModelForm):
"""Edition, d'un groupe , équivalent à un droit """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( permissions = forms.ModelMultipleChoiceField(
Permission.objects.all().select_related('content_type'), Permission.objects.all().select_related('content_type'),
widget=forms.CheckboxSelectMultiple, widget=forms.CheckboxSelectMultiple,
@ -510,23 +510,24 @@ class ListRightForm(FormRevMixin, ModelForm):
class Meta: class Meta:
model = ListRight model = ListRight
fields = ['name', 'unix_name', 'critical', 'permissions', 'details'] fields = ('name', 'unix_name', 'critical', 'permissions', 'details')
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
prefix = kwargs.pop('prefix', self.Meta.model.__name__) prefix = kwargs.pop('prefix', self.Meta.model.__name__)
super(ListRightForm, self).__init__(*args, prefix=prefix, **kwargs) 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): class NewListRightForm(ListRightForm):
"""Ajout d'un groupe/list de droit """ """Ajout d'un groupe/list de droit """
class Meta(ListRightForm.Meta): class Meta(ListRightForm.Meta):
fields = '__all__' fields = ('name', 'unix_name', 'gid', 'critical', 'permissions',
'details')
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(NewListRightForm, self).__init__(*args, **kwargs) super(NewListRightForm, self).__init__(*args, **kwargs)
self.fields['gid'].label = 'Gid, attention, cet attribut ne doit\ self.fields['gid'].label = ("Gid, attention, cet attribut ne doit "
pas être modifié après création' "pas être modifié après création")
class DelListRightForm(Form): class DelListRightForm(Form):

View file

@ -1175,7 +1175,7 @@ class ListRight(RevMixin, AclMixin, Group):
group_ldap = LdapUserGroup.objects.get(gid=self.gid) group_ldap = LdapUserGroup.objects.get(gid=self.gid)
except LdapUserGroup.DoesNotExist: except LdapUserGroup.DoesNotExist:
group_ldap = LdapUserGroup(gid=self.gid) group_ldap = LdapUserGroup(gid=self.gid)
group_ldap.name = self.listright group_ldap.name = self.unix_name
group_ldap.members = [user.pseudo for user group_ldap.members = [user.pseudo for user
in self.user_set.all()] in self.user_set.all()]
group_ldap.save() group_ldap.save()