[gen] Bugfixs.

This commit is contained in:
Gaetan Delannay 2013-09-22 22:08:48 +02:00
parent 1f901e5545
commit bd80d63eda
4 changed files with 16 additions and 20 deletions

View file

@ -26,24 +26,18 @@ class GroupWrapper(AbstractWrapper):
res.append( (role, self.translate('role_%s' % role)) )
return res
def getSelectableUsers(self):
'''Returns all the users, excepted anon and system.'''
return [u for u in self.tool.users if u.login not in ('anon', 'system')]
def validate(self, new, errors):
'''Inter-field validation.'''
return self._callCustom('validate', new, errors)
def addUser(self, user):
'''Adds a p_user to this group.'''
# Update the Ref field.
self.link('users', user)
def removeUser(self, user):
'''Removes a p_user from this group.'''
self.unlink('users', user)
def onEdit(self, created):
# If the group was created by anon, anon can't stay its Owner.
if 'anon' in self.o.__ac_local_roles__:
del self.o.__ac_local_roles__['anon']
if 'system' in self.o.__ac_local_roles__:
del self.o.__ac_local_roles__['system']
# If the group was created by anon|system, anon|system can't stay Owner.
for login in ('anon', 'system'):
if login in self.o.__ac_local_roles__:
del self.o.__ac_local_roles__[login]
return self._callCustom('onEdit', created)
# ------------------------------------------------------------------------------

View file

@ -204,11 +204,10 @@ class UserWrapper(AbstractWrapper):
# "self" must be owned by its Zope user.
if 'Owner' not in self.o.get_local_roles_for_userid(login):
self.o.manage_addLocalRoles(login, ('Owner',))
# If the user was created by anon or system, remove this local role.
if 'anon' in self.o.__ac_local_roles__:
del self.o.__ac_local_roles__['anon']
if 'system' in self.o.__ac_local_roles__:
del self.o.__ac_local_roles__['system']
# If the user was created by anon|system, anon|system can't stay Owner.
for login in ('anon', 'system'):
if login in self.o.__ac_local_roles__:
del self.o.__ac_local_roles__[login]
return self._callCustom('onEdit', created)
def mayEdit(self):