source: publico/ILSAALMaterial/trunk/Extensions/material_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: 10.4 KB
Linha 
1"""Workflow: material_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 setupmaterial_workflow(self, workflow):
40    """Define the material_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='material_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', 'ativo', 'inativo', 'excluido']:
57        workflow.states.addState(s)
58
59    for t in ['salvar', 'ativar', 'inativar', 'excluir']:
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['ativo']
95    stateDef.setProperties(title="""ativo""",
96                           transitions=['inativar'])
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('Access contents information',
107                           1,
108                           ['Almoxarife', 'Authenticated'])
109
110    stateDef = workflow.states['inativo']
111    stateDef.setProperties(title="""inativo""",
112                           transitions=['excluir', 'ativar'])
113    stateDef.setPermission('View',
114                           1,
115                           ['Almoxarife', 'Authenticated'])
116    stateDef.setPermission('Modify portal content',
117                           1,
118                           ['Almoxarife'])
119    stateDef.setPermission('Change portal events',
120                           0,
121                           ['Almoxarife'])
122    stateDef.setPermission('Access contents information',
123                           1,
124                           ['Almoxarife', 'Authenticated'])
125
126    stateDef = workflow.states['excluido']
127    stateDef.setProperties(title="""excluido""",
128                           transitions=[])
129    stateDef.setPermission('View',
130                           0,
131                           ['Almoxarife'])
132    stateDef.setPermission('Change portal events',
133                           0,
134                           ['Almoxarife'])
135    stateDef.setPermission('Access contents information',
136                           0,
137                           ['Almoxarife'])
138
139    ## Transitions initialization
140
141    transitionDef = workflow.transitions['salvar']
142    transitionDef.setProperties(title="""salvar""",
143                                new_state_id="""ativo""",
144                                trigger_type=1,
145                                script_name="""""",
146                                after_script_name="""""",
147                                actbox_name="""salvar""",
148                                actbox_url="""""",
149                                actbox_category="""workflow""",
150                                props={'guard_roles': 'Owner'},
151                                )
152
153    transitionDef = workflow.transitions['ativar']
154    transitionDef.setProperties(title="""ativar""",
155                                new_state_id="""ativo""",
156                                trigger_type=1,
157                                script_name="""""",
158                                after_script_name="""""",
159                                actbox_name="""ativar""",
160                                actbox_url="""""",
161                                actbox_category="""workflow""",
162                                props={'guard_roles': 'Almoxarife'},
163                                )
164
165    transitionDef = workflow.transitions['inativar']
166    transitionDef.setProperties(title="""inativar""",
167                                new_state_id="""inativo""",
168                                trigger_type=1,
169                                script_name="""""",
170                                after_script_name="""""",
171                                actbox_name="""inativar""",
172                                actbox_url="""""",
173                                actbox_category="""workflow""",
174                                props={'guard_roles': 'Almoxarife'},
175                                )
176
177    transitionDef = workflow.transitions['excluir']
178    transitionDef.setProperties(title="""excluir""",
179                                new_state_id="""excluido""",
180                                trigger_type=1,
181                                script_name="""""",
182                                after_script_name="""""",
183                                actbox_name="""excluir""",
184                                actbox_url="""""",
185                                actbox_category="""workflow""",
186                                props={},
187                                )
188
189    ## State Variable
190    workflow.variables.setStateVar('review_state')
191
192    ## Variables initialization
193    variableDef = workflow.variables['review_history']
194    variableDef.setProperties(description="""Provides access to workflow history""",
195                              default_value="""""",
196                              default_expr="""state_change/getHistory""",
197                              for_catalog=0,
198                              for_status=0,
199                              update_always=0,
200                              props={'guard_permissions': 'Request review; Review portal content'})
201
202    variableDef = workflow.variables['comments']
203    variableDef.setProperties(description="""Comments about the last transition""",
204                              default_value="""""",
205                              default_expr="""python:state_change.kwargs.get('comment', '')""",
206                              for_catalog=0,
207                              for_status=1,
208                              update_always=1,
209                              props=None)
210
211    variableDef = workflow.variables['time']
212    variableDef.setProperties(description="""Time of the last transition""",
213                              default_value="""""",
214                              default_expr="""state_change/getDateTime""",
215                              for_catalog=0,
216                              for_status=1,
217                              update_always=1,
218                              props=None)
219
220    variableDef = workflow.variables['actor']
221    variableDef.setProperties(description="""The ID of the user who performed the last transition""",
222                              default_value="""""",
223                              default_expr="""user/getId""",
224                              for_catalog=0,
225                              for_status=1,
226                              update_always=1,
227                              props=None)
228
229    variableDef = workflow.variables['action']
230    variableDef.setProperties(description="""The last transition""",
231                              default_value="""""",
232                              default_expr="""transition/getId|nothing""",
233                              for_catalog=0,
234                              for_status=1,
235                              update_always=1,
236                              props=None)
237
238    ## Worklists Initialization
239
240
241    # WARNING: below protected section is deprecated.
242    # Add a tagged value 'worklist' with the worklist name to your state(s) instead.
243
244    ##code-section create-workflow-setup-method-footer #fill in your manual code here
245    ##/code-section create-workflow-setup-method-footer
246
247
248
249def creatematerial_workflow(self, id):
250    """Create the workflow for ILSAALMaterial.
251    """
252
253    ob = DCWorkflowDefinition(id)
254    setupmaterial_workflow(self, ob)
255    return ob
256
257addWorkflowFactory(creatematerial_workflow,
258                   id='material_workflow',
259                   title='material_workflow')
260
261##code-section create-workflow-module-footer #fill in your manual code here
262##/code-section create-workflow-module-footer
263
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.