2011-11-28 15:50:01 -06:00
|
|
|
# ------------------------------------------------------------------------------
|
2012-05-05 10:04:19 -05:00
|
|
|
from appy.gen import WorkflowOwner
|
2011-12-05 08:11:29 -06:00
|
|
|
from appy.gen.wrappers import AbstractWrapper
|
2011-11-28 15:50:01 -06:00
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
class GroupWrapper(AbstractWrapper):
|
2012-05-05 10:04:19 -05:00
|
|
|
workflow = WorkflowOwner
|
2011-11-28 15:50:01 -06:00
|
|
|
|
|
|
|
def showLogin(self):
|
|
|
|
'''When must we show the login field?'''
|
|
|
|
if self.o.isTemporary(): return 'edit'
|
2013-07-23 10:07:27 -05:00
|
|
|
return ('view', 'result')
|
2011-11-28 15:50:01 -06:00
|
|
|
|
2012-02-21 05:09:42 -06:00
|
|
|
def showGroups(self):
|
|
|
|
'''Only the admin can view or edit roles.'''
|
|
|
|
return self.user.has_role('Manager')
|
|
|
|
|
2011-11-28 15:50:01 -06:00
|
|
|
def validateLogin(self, login):
|
|
|
|
'''Is this p_login valid?'''
|
|
|
|
return True
|
|
|
|
|
|
|
|
def getGrantableRoles(self):
|
|
|
|
'''Returns the list of roles that the admin can grant to a user.'''
|
|
|
|
res = []
|
|
|
|
for role in self.o.getProductConfig().grantableRoles:
|
|
|
|
res.append( (role, self.translate('role_%s' % role)) )
|
|
|
|
return res
|
|
|
|
|
2013-09-22 15:08:48 -05:00
|
|
|
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')]
|
|
|
|
|
2011-11-28 15:50:01 -06:00
|
|
|
def validate(self, new, errors):
|
|
|
|
'''Inter-field validation.'''
|
|
|
|
return self._callCustom('validate', new, errors)
|
|
|
|
|
|
|
|
def onEdit(self, created):
|
2013-09-22 15:08:48 -05:00
|
|
|
# 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]
|
2011-11-28 15:50:01 -06:00
|
|
|
return self._callCustom('onEdit', created)
|
|
|
|
# ------------------------------------------------------------------------------
|