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