source: publico/ILSAALMaterial/trunk/Extensions/itemRequisitado_workflow.py @ 1523

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

Atualizada a versão do ArchGenXml para a 1.4RC2

File size: 11.0 KB
Linha 
1"""Workflow: itemRequisitado_workflow
2"""
3
4# Copyright (c) 2005 by Interlegis
5#
6
7# Generator: ArchGenXML Version 1.4.0-RC2 svn/development
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 setupitemRequisitado_workflow(self, workflow):
40    """Define the itemRequisitado_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 data:
47            data.append(role)
48    portal.__ac_roles__ = tuple(data)
49
50    workflow.setProperties(title='itemRequisitado_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 ['RequisicaoCadastrada', 'cancelado', 'atendidoTotal', 'atendidoParcial', 'novo']:
57        workflow.states.addState(s)
58
59    for t in ['salvar', 'cancelar', 'finalizarTotal', 'finalizarParcial']:
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', 'Change portal events']:
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['RequisicaoCadastrada']
79    stateDef.setProperties(title="""RequisicaoCadastrada""",
80                           transitions=['finalizarTotal', 'finalizarParcial', 'cancelar'])
81    stateDef.setPermission('View',
82                           1,
83                           ['Almoxarife', 'Authenticated'])
84    stateDef.setPermission('Modify portal content',
85                           1,
86                           ['Almoxarife'])
87    stateDef.setPermission('Change Portal events',
88                           1,
89                           ['Almoxarife'])
90    stateDef.setPermission('Access contents information',
91                           1,
92                           ['Almoxarife', 'Authenticated'])
93
94    stateDef = workflow.states['cancelado']
95    stateDef.setProperties(title="""cancelado""",
96                           transitions=[])
97    stateDef.setPermission('View',
98                           0,
99                           ['Owner', 'Almoxarife'])
100    stateDef.setPermission('Change portal events',
101                           0,
102                           ['Almoxarife'])
103    stateDef.setPermission('Access contents information',
104                           0,
105                           ['Owner', 'Almoxarife'])
106
107    stateDef = workflow.states['atendidoTotal']
108    stateDef.setProperties(title="""atendidoTotal""",
109                           transitions=[])
110    stateDef.setPermission('View',
111                           0,
112                           ['Owner', 'Almoxarife'])
113    stateDef.setPermission('Change portal events',
114                           0,
115                           ['Almoxarife'])
116    stateDef.setPermission('Access contents information',
117                           0,
118                           ['Owner', 'Almoxarife'])
119
120    stateDef = workflow.states['atendidoParcial']
121    stateDef.setProperties(title="""atendidoParcial""",
122                           transitions=[])
123    stateDef.setPermission('View',
124                           0,
125                           ['Owner', 'Almoxarife'])
126    stateDef.setPermission('Change portal events',
127                           0,
128                           ['Almoxarife'])
129    stateDef.setPermission('Access contents information',
130                           0,
131                           ['Owner', 'Almoxarife'])
132
133    stateDef = workflow.states['novo']
134    stateDef.setProperties(title="""novo""",
135                           transitions=['salvar'])
136    stateDef.setPermission('View',
137                           0,
138                           ['Owner'])
139    stateDef.setPermission('Modify portal content',
140                           0,
141                           ['Owner'])
142    stateDef.setPermission('Change portal events',
143                           0,
144                           ['Owner'])
145    stateDef.setPermission('Access contents information',
146                           0,
147                           ['Owner'])
148
149    ## Transitions initialization
150
151    transitionDef = workflow.transitions['salvar']
152    transitionDef.setProperties(title="""salvar""",
153                                new_state_id="""RequisicaoCadastrada""",
154                                trigger_type=1,
155                                script_name="""""",
156                                after_script_name="""""",
157                                actbox_name="""salvar""",
158                                actbox_url="""""",
159                                actbox_category="""workflow""",
160                                props={'guard_roles': 'Owner'},
161                                )
162
163    transitionDef = workflow.transitions['cancelar']
164    transitionDef.setProperties(title="""cancelar""",
165                                new_state_id="""cancelado""",
166                                trigger_type=1,
167                                script_name="""""",
168                                after_script_name="""""",
169                                actbox_name="""cancelar""",
170                                actbox_url="""""",
171                                actbox_category="""workflow""",
172                                props={},
173                                )
174
175    transitionDef = workflow.transitions['finalizarTotal']
176    transitionDef.setProperties(title="""finalizarTotal""",
177                                new_state_id="""atendidoTotal""",
178                                trigger_type=1,
179                                script_name="""""",
180                                after_script_name="""""",
181                                actbox_name="""finalizarTotal""",
182                                actbox_url="""""",
183                                actbox_category="""workflow""",
184                                props={},
185                                )
186
187    transitionDef = workflow.transitions['finalizarParcial']
188    transitionDef.setProperties(title="""finalizarParcial""",
189                                new_state_id="""atendidoParcial""",
190                                trigger_type=1,
191                                script_name="""""",
192                                after_script_name="""""",
193                                actbox_name="""finalizarParcial""",
194                                actbox_url="""""",
195                                actbox_category="""workflow""",
196                                props={},
197                                )
198
199    ## State Variable
200    workflow.variables.setStateVar('review_state')
201
202    ## Variables initialization
203    variableDef = workflow.variables['review_history']
204    variableDef.setProperties(description="""Provides access to workflow history""",
205                              default_value="""""",
206                              default_expr="""state_change/getHistory""",
207                              for_catalog=0,
208                              for_status=0,
209                              update_always=0,
210                              props={'guard_permissions': 'Request review; Review portal content'})
211
212    variableDef = workflow.variables['comments']
213    variableDef.setProperties(description="""Comments about the last transition""",
214                              default_value="""""",
215                              default_expr="""python:state_change.kwargs.get('comment', '')""",
216                              for_catalog=0,
217                              for_status=1,
218                              update_always=1,
219                              props=None)
220
221    variableDef = workflow.variables['time']
222    variableDef.setProperties(description="""Time of the last transition""",
223                              default_value="""""",
224                              default_expr="""state_change/getDateTime""",
225                              for_catalog=0,
226                              for_status=1,
227                              update_always=1,
228                              props=None)
229
230    variableDef = workflow.variables['actor']
231    variableDef.setProperties(description="""The ID of the user who performed the last transition""",
232                              default_value="""""",
233                              default_expr="""user/getId""",
234                              for_catalog=0,
235                              for_status=1,
236                              update_always=1,
237                              props=None)
238
239    variableDef = workflow.variables['action']
240    variableDef.setProperties(description="""The last transition""",
241                              default_value="""""",
242                              default_expr="""transition/getId|nothing""",
243                              for_catalog=0,
244                              for_status=1,
245                              update_always=1,
246                              props=None)
247
248    ## Worklists Initialization
249
250
251    # WARNING: below protected section is deprecated.
252    # Add a tagged value 'worklist' with the worklist name to your state(s) instead.
253
254    ##code-section create-workflow-setup-method-footer #fill in your manual code here
255    ##/code-section create-workflow-setup-method-footer
256
257
258
259def createitemRequisitado_workflow(self, id):
260    """Create the workflow for ILSAALMaterial.
261    """
262
263    ob = DCWorkflowDefinition(id)
264    setupitemRequisitado_workflow(self, ob)
265    return ob
266
267addWorkflowFactory(createitemRequisitado_workflow,
268                   id='itemRequisitado_workflow',
269                   title='itemRequisitado_workflow')
270
271##code-section create-workflow-module-footer #fill in your manual code here
272##/code-section create-workflow-module-footer
273
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.