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