def testGetPreviousWorkflowState(self): """Test ``utils.getPreviousWorkflowState()``.""" wtool = getToolByName(self.portal, 'portal_workflow') document = self.portal.folder.document1 self.failUnlessEqual(getPreviousWorkflowState(document), None) state = wtool.getInfoFor(document, 'review_state') wtool.doActionFor(document, 'publish') self.failUnlessEqual(getPreviousWorkflowState(document), state)
def onWorkflowTransition(self, obj, action): """Handler called when a workflow transition is triggered. It returns the number of mails which have been sent. """ if not self.getProperty('wf_transition_notification_enabled'): return 0 if self.ignoreNotification(obj): return 0 wtool = getToolByName(self, 'portal_workflow') comments = wtool.getInfoFor(obj, 'comments') extra_bindings = getBasicBindings(obj) extra_bindings.update({'transition': action, 'comments': comments, 'previous_state': getPreviousWorkflowState(obj)}) return self._handlerHelper(obj, 'wf_transition', extra_bindings)
def onWorkflowTransition(self, obj, action): """Handler called when a workflow transition is triggered. It returns the number of mails which have been sent. """ if not self.getProperty('wf_transition_notification_enabled'): return 0 if self.ignoreNotification(obj): return 0 wtool = getToolByName(self, 'portal_workflow') comments = wtool.getInfoFor(obj, 'comments') extra_bindings = getBasicBindings(obj) extra_bindings.update({ 'transition': action, 'comments': comments, 'previous_state': getPreviousWorkflowState(obj) }) current_state_display = extra_bindings['current_state'] previous_state_display = extra_bindings['previous_state'] try: wf_def = wtool.getWorkflowsFor(obj) if len(wf_def) > 0: curr_wf = wf_def[0] wf_states = curr_wf.states current_state_display = wf_states[ extra_bindings['current_state']].title if extra_bindings['previous_state'] <> None: previous_state_display = wf_states[ extra_bindings['previous_state']].title else: previous_state_display = "" except AttributeError: pass extra_bindings.update({ 'current_state_title': current_state_display, 'previous_state_title': previous_state_display, }) return self._handlerHelper(obj, 'wf_transition', extra_bindings, extra_bindings, extra_bindings)
def onWorkflowTransition(self, obj, action): """Handler called when a workflow transition is triggered. It returns the number of mails which have been sent. """ if not self.getProperty('wf_transition_notification_enabled'): return 0 if self.ignoreNotification(obj): return 0 wtool = getToolByName(self, 'portal_workflow') comments = wtool.getInfoFor(obj, 'comments') extra_bindings = getBasicBindings(obj) extra_bindings.update({ 'transition': action, 'comments': comments, 'previous_state': getPreviousWorkflowState(obj) }) return self._handlerHelper(obj, 'wf_transition', extra_bindings)
def onWorkflowTransition(self, obj, action): """Handler called when a workflow transition is triggered. It returns the number of mails which have been sent. """ if not self.getProperty('wf_transition_notification_enabled'): return 0 if self.ignoreNotification(obj): return 0 wtool = getToolByName(self, 'portal_workflow') comments = wtool.getInfoFor(obj, 'comments') extra_bindings = getBasicBindings(obj) extra_bindings.update({'transition': action, 'comments': comments, 'previous_state': getPreviousWorkflowState(obj)}) current_state_display = extra_bindings['current_state'] previous_state_display = extra_bindings['previous_state'] try: wf_def = wtool.getWorkflowsFor(obj) if len(wf_def) > 0: curr_wf = wf_def[0] wf_states = curr_wf.states current_state_display = wf_states[extra_bindings['current_state']].title if extra_bindings['previous_state'] <> None: previous_state_display = wf_states[extra_bindings['previous_state']].title else: previous_state_display = "" except AttributeError: pass extra_bindings.update({'current_state_title': current_state_display, 'previous_state_title': previous_state_display,}) return self._handlerHelper(obj, 'wf_transition', extra_bindings, extra_bindings, extra_bindings)