source: publico/ILSAALMaterial/trunk/Extensions/fechamento_workflow.py @ 1540

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

novo codigo gerado

File size: 9.3 KB
Linha 
1"""Workflow: fechamento_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 = 'ILSAALMaterial'
38
39def setupfechamento_workflow(self, workflow):
40    """Define the fechamento_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 ['Almoxarife']:
46        if not role in self.__ac_roles__:
47            data.append(role)
48    portal.__ac_roles__ = tuple(data)
49
50    workflow.setProperties(title='fechamento_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', 'aberto', 'fechado']:
57        workflow.states.addState(s)
58
59    for t in ['salvar', 'abrir', 'fechar']:
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', 'Add Consolidacao Content']:
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['aberto']
95    stateDef.setProperties(title="""aberto""",
96                           transitions=['fechar'])
97    stateDef.setPermission('View',
98                           1,
99                           ['Almoxarife', 'Authenticated'])
100    stateDef.setPermission('Modify portal content',
101                           1,
102                           ['Almoxarife'])
103    stateDef.setPermission('Change portal events',
104                           0,
105                           ['Almoxarife'])
106    stateDef.setPermission('Add Consolidacao Content',
107                           0,
108                           ['Almoxarife'])
109    stateDef.setPermission('Access contents information',
110                           1,
111                           ['Almoxarife', 'Authenticated'])
112
113    stateDef = workflow.states['fechado']
114    stateDef.setProperties(title="""fechado""",
115                           transitions=['abrir'])
116    stateDef.setPermission('View',
117                           0,
118                           ['Almoxarife'])
119    stateDef.setPermission('Change portal events',
120                           0,
121                           ['Almoxarife'])
122    stateDef.setPermission('Access contents information',
123                           0,
124                           ['Almoxarife'])
125
126    ## Transitions initialization
127
128    transitionDef = workflow.transitions['salvar']
129    transitionDef.setProperties(title="""salvar""",
130                                new_state_id="""aberto""",
131                                trigger_type=1,
132                                script_name="""""",
133                                after_script_name="""""",
134                                actbox_name="""salvar""",
135                                actbox_url="""""",
136                                actbox_category="""workflow""",
137                                props={'guard_roles': 'Owner'},
138                                )
139
140    transitionDef = workflow.transitions['abrir']
141    transitionDef.setProperties(title="""abrir""",
142                                new_state_id="""aberto""",
143                                trigger_type=1,
144                                script_name="""""",
145                                after_script_name="""""",
146                                actbox_name="""abrir""",
147                                actbox_url="""""",
148                                actbox_category="""workflow""",
149                                props={'guard_roles': 'Almoxarife'},
150                                )
151
152    transitionDef = workflow.transitions['fechar']
153    transitionDef.setProperties(title="""fechar""",
154                                new_state_id="""fechado""",
155                                trigger_type=1,
156                                script_name="""""",
157                                after_script_name="""""",
158                                actbox_name="""fechar""",
159                                actbox_url="""""",
160                                actbox_category="""workflow""",
161                                props={'guard_roles': 'Almoxarife'},
162                                )
163
164    ## State Variable
165    workflow.variables.setStateVar('review_state')
166
167    ## Variables initialization
168    variableDef = workflow.variables['review_history']
169    variableDef.setProperties(description="""Provides access to workflow history""",
170                              default_value="""""",
171                              default_expr="""state_change/getHistory""",
172                              for_catalog=0,
173                              for_status=0,
174                              update_always=0,
175                              props={'guard_permissions': 'Request review; Review portal content'})
176
177    variableDef = workflow.variables['comments']
178    variableDef.setProperties(description="""Comments about the last transition""",
179                              default_value="""""",
180                              default_expr="""python:state_change.kwargs.get('comment', '')""",
181                              for_catalog=0,
182                              for_status=1,
183                              update_always=1,
184                              props=None)
185
186    variableDef = workflow.variables['time']
187    variableDef.setProperties(description="""Time of the last transition""",
188                              default_value="""""",
189                              default_expr="""state_change/getDateTime""",
190                              for_catalog=0,
191                              for_status=1,
192                              update_always=1,
193                              props=None)
194
195    variableDef = workflow.variables['actor']
196    variableDef.setProperties(description="""The ID of the user who performed the last transition""",
197                              default_value="""""",
198                              default_expr="""user/getId""",
199                              for_catalog=0,
200                              for_status=1,
201                              update_always=1,
202                              props=None)
203
204    variableDef = workflow.variables['action']
205    variableDef.setProperties(description="""The last transition""",
206                              default_value="""""",
207                              default_expr="""transition/getId|nothing""",
208                              for_catalog=0,
209                              for_status=1,
210                              update_always=1,
211                              props=None)
212
213    ## Worklists Initialization
214
215
216    # WARNING: below protected section is deprecated.
217    # Add a tagged value 'worklist' with the worklist name to your state(s) instead.
218
219    ##code-section create-workflow-setup-method-footer #fill in your manual code here
220    ##/code-section create-workflow-setup-method-footer
221
222
223
224def createfechamento_workflow(self, id):
225    """Create the workflow for ILSAALMaterial.
226    """
227
228    ob = DCWorkflowDefinition(id)
229    setupfechamento_workflow(self, ob)
230    return ob
231
232addWorkflowFactory(createfechamento_workflow,
233                   id='fechamento_workflow',
234                   title='fechamento_workflow')
235
236##code-section create-workflow-module-footer #fill in your manual code here
237##/code-section create-workflow-module-footer
238
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.