source: publico/ILSAALTesouraria/trunk/Extensions/conciliacao_workflow.py @ 1086

Última Alteração nesse arquivo desde 1086 foi 1086, incluída por jeanferri, 14 anos atrás

Adicionado o workflow da conciliação

File size: 8.5 KB
Linha 
1"""Workflow: conciliacao_workflow
2"""
3
4# Copyright (c) 2005 by Interlegis
5#
6
7# Generator: ArchGenXML Version 1.4.0-RC1 devel
8#            http://plone.org/products/archgenxml
9#
10# GNU General Public Licence (GPL)
11#
12# This program is free software; you can redistribute it and/or modify it under
13# the terms of the GNU General Public License as published by the Free Software
14# Foundation; either version 2 of the License, or (at your option) any later
15# version.
16# This program is distributed in the hope that it will be useful, but WITHOUT
17# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
19# details.
20# You should have received a copy of the GNU General Public License along with
21# this program; if not, write to the Free Software Foundation, Inc., 59 Temple
22# Place, Suite 330, Boston, MA  02111-1307  USA
23#
24__author__    = '''STC Interlegis <stc@interlegis.gov.br>'''
25__docformat__ = 'plaintext'
26__version__   = '$ Revision 0.0 $'[11:-2]
27
28from Products.CMFCore.utils import getToolByName
29from Products.CMFCore.WorkflowTool import addWorkflowFactory
30from Products.DCWorkflow.DCWorkflow import DCWorkflowDefinition
31from Products.ExternalMethod.ExternalMethod import ExternalMethod
32
33##code-section create-workflow-module-header #fill in your manual code here
34##/code-section create-workflow-module-header
35
36
37productname = 'ILSAALTesouraria'
38
39def setupconciliacao_workflow(self, workflow):
40    """Define the conciliacao_workflow workflow.
41    """
42    # add additional roles to portal
43    portal = getToolByName(self,'portal_url').getPortalObject()
44    data = list(portal.__ac_roles__)
45    for role in ['Tesoureiro']:
46        if not role in self.__ac_roles__:
47            data.append(role)
48    portal.__ac_roles__ = tuple(data)
49
50    workflow.setProperties(title='conciliacao_workflow')
51
52    ##code-section create-workflow-setup-method-header #fill in your manual code here
53    ##/code-section create-workflow-setup-method-header
54
55
56    for s in ['novo', 'a_conciliar', 'conciliado']:
57        workflow.states.addState(s)
58
59    for t in ['salvar', 'conciliar']:
60        workflow.transitions.addTransition(t)
61
62    for v in ['review_history', 'comments', 'time', 'actor', 'action']:
63        workflow.variables.addVariable(v)
64
65    for p in ['View', 'Modify portal content', 'Change portal events', 'Access contents information']:
66        workflow.addManagedPermission(p)
67
68    for l in []:
69        if not l in workflow.worklists.objectValues():
70            workflow.worklists.addWorklist(l)
71
72    ## Initial State
73
74    workflow.states.setInitialState('novo')
75
76    ## States initialization
77
78    stateDef = workflow.states['novo']
79    stateDef.setProperties(title="""novo""",
80                           transitions=['salvar'])
81    stateDef.setPermission('View',
82                           0,
83                           ['Owner'])
84    stateDef.setPermission('Modify portal content',
85                           0,
86                           ['Owner'])
87    stateDef.setPermission('Change portal events',
88                           0,
89                           ['Owner'])
90    stateDef.setPermission('Access contents information',
91                           0,
92                           ['Owner'])
93
94    stateDef = workflow.states['a_conciliar']
95    stateDef.setProperties(title="""a_conciliar""",
96                           transitions=['conciliar'])
97    stateDef.setPermission('View',
98                           0,
99                           ['Tesoureiro'])
100    stateDef.setPermission('Modify portal content',
101                           0,
102                           ['Tesoureiro'])
103    stateDef.setPermission('Change portal events',
104                           0,
105                           ['Tesoureiro'])
106    stateDef.setPermission('Access contents information',
107                           0,
108                           ['Tesoureiro'])
109
110    stateDef = workflow.states['conciliado']
111    stateDef.setProperties(title="""conciliado""",
112                           transitions=[])
113    stateDef.setPermission('View',
114                           0,
115                           ['Tesoureiro'])
116    stateDef.setPermission('Access contents information',
117                           0,
118                           ['Tesoureiro'])
119
120    ## Transitions initialization
121
122    transitionDef = workflow.transitions['salvar']
123    transitionDef.setProperties(title="""salvar""",
124                                new_state_id="""a_conciliar""",
125                                trigger_type=1,
126                                script_name="""""",
127                                after_script_name="""""",
128                                actbox_name="""salvar""",
129                                actbox_url="""""",
130                                actbox_category="""workflow""",
131                                props={'guard_roles': 'Owner'},
132                                )
133
134    transitionDef = workflow.transitions['conciliar']
135    transitionDef.setProperties(title="""conciliar""",
136                                new_state_id="""conciliado""",
137                                trigger_type=1,
138                                script_name="""""",
139                                after_script_name="""""",
140                                actbox_name="""conciliar""",
141                                actbox_url="""""",
142                                actbox_category="""workflow""",
143                                props={'guard_roles': 'Tesoureiro'},
144                                )
145
146    ## State Variable
147    workflow.variables.setStateVar('review_state')
148
149    ## Variables initialization
150    variableDef = workflow.variables['review_history']
151    variableDef.setProperties(description="""Provides access to workflow history""",
152                              default_value="""""",
153                              default_expr="""state_change/getHistory""",
154                              for_catalog=0,
155                              for_status=0,
156                              update_always=0,
157                              props={'guard_permissions': 'Request review; Review portal content'})
158
159    variableDef = workflow.variables['comments']
160    variableDef.setProperties(description="""Comments about the last transition""",
161                              default_value="""""",
162                              default_expr="""python:state_change.kwargs.get('comment', '')""",
163                              for_catalog=0,
164                              for_status=1,
165                              update_always=1,
166                              props=None)
167
168    variableDef = workflow.variables['time']
169    variableDef.setProperties(description="""Time of the last transition""",
170                              default_value="""""",
171                              default_expr="""state_change/getDateTime""",
172                              for_catalog=0,
173                              for_status=1,
174                              update_always=1,
175                              props=None)
176
177    variableDef = workflow.variables['actor']
178    variableDef.setProperties(description="""The ID of the user who performed the last transition""",
179                              default_value="""""",
180                              default_expr="""user/getId""",
181                              for_catalog=0,
182                              for_status=1,
183                              update_always=1,
184                              props=None)
185
186    variableDef = workflow.variables['action']
187    variableDef.setProperties(description="""The last transition""",
188                              default_value="""""",
189                              default_expr="""transition/getId|nothing""",
190                              for_catalog=0,
191                              for_status=1,
192                              update_always=1,
193                              props=None)
194
195    ## Worklists Initialization
196
197
198    # WARNING: below protected section is deprecated.
199    # Add a tagged value 'worklist' with the worklist name to your state(s) instead.
200
201    ##code-section create-workflow-setup-method-footer #fill in your manual code here
202    ##/code-section create-workflow-setup-method-footer
203
204
205
206def createconciliacao_workflow(self, id):
207    """Create the workflow for ILSAALTesouraria.
208    """
209
210    ob = DCWorkflowDefinition(id)
211    setupconciliacao_workflow(self, ob)
212    return ob
213
214addWorkflowFactory(createconciliacao_workflow,
215                   id='conciliacao_workflow',
216                   title='conciliacao_workflow')
217
218##code-section create-workflow-module-footer #fill in your manual code here
219##/code-section create-workflow-module-footer
220
Note: Veja TracBrowser para ajuda no uso do navegador do trac.
 

The contents and data of this website are published under license:
Creative Commons 4.0 Brasil - Atribuir Fonte - Compartilhar Igual.