source: ZMS/trunk/ZMSWorkflowItem.py @ 1557

Revision 1557, 3.5 KB checked in by zmsdev, 11 months ago (diff)

removed old zms artefacts

Line 
1################################################################################
2# _workflowmanager.py
3#
4# This program is free software; you can redistribute it and/or
5# modify it under the terms of the GNU General Public License
6# as published by the Free Software Foundation; either version 2
7# of the License, or (at your option) any later version.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program; if not, write to the Free Software
16# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
17################################################################################
18
19
20class ZMSWorkflowItem:
21
22    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
23    ZMSWorkflowItem.getAutocommit
24   
25    Returns true if auto-commit is active (workflow is inactive), false otherwise.
26    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
27    def getAutocommit(self):
28      workflow_manager = getattr(self,'workflow_manager',None)
29      if workflow_manager is None:
30        autocommit = True
31      else:
32        autocommit = False
33        if not autocommit:
34          autocommit = autocommit or workflow_manager.getAutocommit()
35        if not autocommit:
36          baseurl = self.getDocumentElement().absolute_url()
37          url = self.absolute_url()
38          if len( url) > len( baseurl):
39            url = url[ len( baseurl)+1:]
40          url = '$'+url
41          found = False
42          nodes = workflow_manager.getNodes()
43          for node in nodes:
44            if url.find(node[1:-1]) == 0:
45              found = True
46              break
47          autocommit = autocommit or not found
48      return autocommit
49
50
51    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
52    ZMSWorkflowItem.filtered_workflow_actions:
53    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
54    def filtered_workflow_actions(self, path=''):
55      actions = []
56      REQUEST = self.REQUEST
57      lang = REQUEST['lang']
58      auth_user = REQUEST['AUTHENTICATED_USER']
59     
60      #-- Workflow.
61      if not self.getAutocommit() and self.isVersionContainer():
62        wfStates = self.getWfStates(REQUEST)
63        transitions = self.workflow_manager.getTransitions()
64        roles = self.getUserRoles(auth_user)
65        for transition in transitions:
66          wfFrom = transition.get('from',[])
67          wfPerformer = transition.get('performer',[])
68          wfTo = transition.get('to',[])
69          append = False
70          append = append or ((wfFrom is None or len(wfFrom) == 0) and len(wfTo) == 0)
71          append = append or (len(self.intersection_list(wfStates,wfFrom)) > 0 and len(wfTo) > 0)
72          append = append and (len(self.intersection_list(roles,wfPerformer)) > 0 or auth_user.has_permission('Manager',self))
73          if append:
74            actions.append((transition['name'],path+'manage_wfTransition'))
75     
76      #-- Headline,
77      if len( actions) > 0:
78        actions.insert(0,('----- %s -----'%self.getZMILangStr('TAB_WORKFLOW'),''))
79     
80      # Return action list.
81      return actions
82
83################################################################################
Note: See TracBrowser for help on using the repository browser.