[gen]: method Wrapper.do: added param 'noSecurity' allowing to bypass check of roles mentioned as conditions for triggering worfklow actions.
This commit is contained in:
parent
699cc8346b
commit
178059ba1b
|
@ -2631,7 +2631,7 @@ class Transition:
|
|||
break
|
||||
return res
|
||||
|
||||
def isTriggerable(self, obj, wf):
|
||||
def isTriggerable(self, obj, wf, noSecurity=False):
|
||||
'''Can this transition be triggered on p_obj?'''
|
||||
wf = wf.__instance__ # We need the prototypical instance here.
|
||||
# Checks that the current state of the object is a start state for this
|
||||
|
@ -2651,6 +2651,7 @@ class Transition:
|
|||
if isinstance(self.condition, Role):
|
||||
# Condition is a role. Transition may be triggered if the user has
|
||||
# this role.
|
||||
if noSecurity: return True
|
||||
return user.has_role(self.condition.name, obj)
|
||||
elif type(self.condition) == types.FunctionType:
|
||||
return self.condition(wf, obj.appy())
|
||||
|
@ -2663,7 +2664,7 @@ class Transition:
|
|||
if isinstance(roleOrFunction, basestring):
|
||||
if hasRole == None:
|
||||
hasRole = False
|
||||
if user.has_role(roleOrFunction, obj):
|
||||
if user.has_role(roleOrFunction, obj) or noSecurity:
|
||||
hasRole = True
|
||||
elif type(roleOrFunction) == types.FunctionType:
|
||||
if not roleOrFunction(wf, obj.appy()):
|
||||
|
|
|
@ -1071,7 +1071,7 @@ class BaseMixin:
|
|||
return self.goto(msg)
|
||||
|
||||
def trigger(self, transitionName, comment='', doAction=True, doNotify=True,
|
||||
doHistory=True, doSay=True):
|
||||
doHistory=True, doSay=True, noSecurity=False):
|
||||
'''Triggers transition named p_transitionName.'''
|
||||
# Check that this transition exists.
|
||||
wf = self.getWorkflow()
|
||||
|
@ -1080,7 +1080,7 @@ class BaseMixin:
|
|||
raise 'Transition "%s" was not found.' % transitionName
|
||||
# Is this transition triggerable?
|
||||
transition = getattr(wf, transitionName)
|
||||
if not transition.isTriggerable(self, wf):
|
||||
if not transition.isTriggerable(self, wf, noSecurity=noSecurity):
|
||||
raise 'Transition "%s" can\'t be triggered.' % transitionName
|
||||
# Trigger the transition
|
||||
transition.trigger(transitionName, self, wf, comment, doAction=doAction,
|
||||
|
|
|
@ -86,9 +86,9 @@
|
|||
<td tal:condition="isDataChange" tal:content="python: _('data_change')"></td>
|
||||
<td tal:condition="not: isDataChange"
|
||||
tal:content="python: _(contextObj.getWorkflowLabel(event['action']))"/>
|
||||
<td tal:define="actorid python:event.get('actor')"
|
||||
tal:content="python: tool.getUserName(actorid)"/>
|
||||
<td tal:content="event/time"/>
|
||||
<td tal:define="actorId python:event.get('actor')"
|
||||
tal:content="python: tool.getUserName(actorId)"/>
|
||||
<td tal:content="python: tool.formatDate(event['time'], withHour=True)"/>
|
||||
<td tal:condition="not: isDataChange">
|
||||
<tal:c condition="rhComments"
|
||||
content="structure python: contextObj.formatText(rhComments)"/>
|
||||
|
|
|
@ -255,11 +255,12 @@ class AbstractWrapper(object):
|
|||
format=format)
|
||||
|
||||
def do(self, transition, comment='', doAction=True, doNotify=True,
|
||||
doHistory=True):
|
||||
doHistory=True, noSecurity=False):
|
||||
'''This method allows to trigger on p_self a workflow p_transition
|
||||
programmatically. See doc in self.o.do.'''
|
||||
return self.o.trigger(transition, comment, doAction=doAction,
|
||||
doNotify=doNotify, doHistory=doHistory, doSay=False)
|
||||
doNotify=doNotify, doHistory=doHistory,
|
||||
doSay=False, noSecurity=noSecurity)
|
||||
|
||||
def log(self, message, type='info'): return self.o.log(message, type)
|
||||
def say(self, message, type='info'): return self.o.say(message, type)
|
||||
|
|
Loading…
Reference in a new issue