source: waeup_product/trunk/Workflows/WAeUPWorkflow.py @ 22

Last change on this file since 22 was 19, checked in by joachim, 19 years ago

initial import

  • Property svn:keywords set to Id
File size: 18.7 KB
Line 
1""" WAeUP Workflfow
2"""
3
4__author__ = "Joachim Schmitz <js@aixtraware.de>"
5
6import os, sys
7from zLOG import LOG, INFO, DEBUG
8
9from Products.CMFCore.permissions import View, ModifyPortalContent
10#from Products.WAeUP.permissions import
11
12from Products.CPSWorkflow.transitions import \
13     TRANSITION_INITIAL_CREATE, \
14     TRANSITION_ALLOWSUB_CHECKOUT, \
15     TRANSITION_ALLOWSUB_CREATE, \
16     TRANSITION_ALLOWSUB_DELETE, \
17     TRANSITION_ALLOWSUB_MOVE, \
18     TRANSITION_ALLOWSUB_COPY
19
20from Products.DCWorkflow.Transitions import \
21     TRIGGER_USER_ACTION
22
23def waeupWorkflowsInstall(self):
24    """Install the workflow for the WAeUP Types
25    """
26
27    portal = self.portal_url.getPortalObject()
28    wftool = portal.portal_workflow
29
30    wfids = wftool.objectIds()
31    wfid = 'waeup_section_wf'
32
33    if wfid in wfids:
34        wftool.manage_delObjects([wfid])
35
36    wftool.manage_addWorkflow(id=wfid,
37                              workflow_type='cps_workflow (Web-configurable workflow for CPS)')
38
39    wf = wftool[wfid]
40
41    for p in (View,
42              ModifyPortalContent,
43             ):
44        wf.addManagedPermission(p)
45
46    ###########################################################################
47    ###########################################################################
48
49    #                                  STATES
50
51    ###########################################################################
52    ###########################################################################
53
54    for s in ('work',
55             ):
56        wf.states.addState(s)
57
58    ##########################################################################
59    #                                  WORK
60    ##########################################################################
61
62    s = wf.states.get('work')
63
64    s.setPermission(View, 1, ('Student',))
65    s.setPermission(ModifyPortalContent, 1, ('StudentAdmin',))
66
67    s.setInitialState('work')
68    s.setProperties(title='Work',
69                    description='',
70                    transitions=('create_content',
71                                 'cut_copy_paste',
72                                 'close',),)
73
74    ##########################################################################
75    #                                  CLOSED
76    ##########################################################################
77
78##    s = wf.states.get('closed')
79##
80##    s.setPermission(View, 1, ('ChatPoster',))
81##    s.setPermission(ModifyPortalContent, 1, ('ChatModerator',))
82##    s.setPermission(chatReply, 1, ('ChatModerator',))
83##    s.setPermission(chatPost, 1, ('ChatModerator',))
84##    s.setPermission(chatModerate, 1, ('ChatModerator',))
85
86##    s.setProperties(title='Closed',
87##                    description='',
88##                    transitions=('unclose',
89##                                 'cut_copy_paste',),)
90##
91    ###########################################################################
92    ###########################################################################
93
94    #                               TRANSITIONS
95
96    ###########################################################################
97    ###########################################################################
98
99    for t in ('create',
100              'create_content',
101              'cut_copy_paste',
102              ):
103        wf.transitions.addTransition(t)
104
105
106    ###########################################################################
107    #                                 CREATE
108    ###########################################################################
109
110    t = wf.transitions.get('create')
111    t.setProperties(title='Initial creation',
112                    description='Intial transition like',
113                    new_state_id='work',
114                    transition_behavior=(TRANSITION_INITIAL_CREATE, ),
115                    clone_allowed_transitions=None,
116                    actbox_name='', actbox_category='workflow', actbox_url='',
117                    props={'guard_permissions':'',
118                           'guard_roles':'Manager; SectionManager',
119                           'guard_expr':''},)
120
121    ###########################################################################
122    #                                  CREATE CONTENT
123    ###########################################################################
124
125    t = wf.transitions.get('create_content')
126    t.setProperties(title='Create content',
127                    description='Allow sub Object Create',
128                    new_state_id='work',
129                    transition_behavior=(TRANSITION_ALLOWSUB_CREATE,
130                                         TRANSITION_ALLOWSUB_CHECKOUT,),
131                    trigger_type=TRIGGER_USER_ACTION,
132                    actbox_name='New',
133                    actbox_category='',
134                    actbox_url='',
135                    props={'guard_permissions':'',
136                           'guard_roles':'Manager; SectionManager; SectionReviewer; SectionReader',
137                           'guard_expr':''},)
138
139    ##########################################################################
140    #                                  CUT/COPY/PASTE
141    ##########################################################################
142
143    t = wf.transitions.get('cut_copy_paste')
144    t.setProperties(title='Cut/Copy/Paste',
145                    new_state_id='work',
146                    transition_behavior=(TRANSITION_ALLOWSUB_DELETE,
147                                         TRANSITION_ALLOWSUB_MOVE,
148                                         TRANSITION_ALLOWSUB_COPY),
149                    clone_allowed_transitions=None,
150                    trigger_type=TRIGGER_USER_ACTION,
151                    actbox_name='New',
152                    actbox_category='',
153                    actbox_url='',
154                    props={'guard_permissions':'',
155                           'guard_roles':'Manager; SectionManager',
156                           'guard_expr':''},)
157
158    ##########################################################################
159    #                                  CLOSE
160    ##########################################################################
161
162##    t = wf.transitions.get('close')
163##    t.setProperties(title='close',
164##                    new_state_id='closed',
165##                    transition_behavior=(),
166##                    clone_allowed_transitions=None,
167##                    trigger_type=TRIGGER_USER_ACTION,
168##                    actbox_name='label_chat_close',
169##                    actbox_category='workflow',
170##                    actbox_url='%(content_url)s/cps_chat_close',
171##                    props={'guard_permissions':'',
172##                           'guard_roles':'Manager; SectionManager; SectionReviewer',
173##                           'guard_expr':''},)
174##
175##    ##########################################################################
176##    #                                  UNCLOSE
177##    ##########################################################################
178##
179##    t = wf.transitions.get('unclose')
180##    t.setProperties(title='unclose',
181##                    new_state_id='work',
182##                    transition_behavior=(),
183##                    clone_allowed_transitions=None,
184##                    trigger_type=TRIGGER_USER_ACTION,
185##                    actbox_name='label_chat_unclose',
186##                    actbox_category='workflow',
187##                    actbox_url='%(content_url)s/cps_chat_unclose',
188##                    props={'guard_permissions':'',
189##                           'guard_roles':'Manager; SectionManager; SectionReviewer',
190##                           'guard_expr':''},)
191
192    ################################################################
193    #                 VARIABLES
194    ################################################################
195
196    for v in ('action',
197              'actor',
198              'comments',
199              'review_history',
200              'time',
201              'dest_container',
202              ):
203        wf.variables.addVariable(v)
204
205
206    wf.variables.setStateVar('review_state')
207
208    vdef = wf.variables['action']
209    vdef.setProperties(description='The last transition',
210                       default_expr='transition/getId|nothing',
211                       for_status=1, update_always=1)
212
213    vdef = wf.variables['actor']
214    vdef.setProperties(description='The ID of the user who performed '
215                       'the last transition',
216                       default_expr='user/getId',
217                       for_status=1, update_always=1)
218
219    vdef = wf.variables['comments']
220    vdef.setProperties(description='Comments about the last transition',
221                       default_expr="python:state_change.kwargs.get('comment', '')",
222                       for_status=1, update_always=1)
223
224    vdef = wf.variables['review_history']
225    vdef.setProperties(description='Provides access to workflow history',
226                       default_expr="state_change/getHistory",
227                       props={'guard_permissions':'',
228                              'guard_roles':'Manager; WorkspaceManager; WorkspaceMember; WorkspaceReader; Member',
229                              'guard_expr':''})
230
231    vdef = wf.variables['time']
232    vdef.setProperties(description='Time of the last transition',
233                       default_expr="state_change/getDateTime",
234                       for_status=1, update_always=1)
235
236    vdef = wf.variables['dest_container']
237    vdef.setProperties(description='Destination container for the last paste/publish',
238                       default_expr="python:state_change.kwargs.get('dest_container', '')",
239                       for_status=1, update_always=1)
240
241
242    ######################################################################################
243    ######################################################################################
244    wfid = 'waeup_workspace_wf'
245
246    if wfid in wfids:
247        wftool.manage_delObjects([wfid])
248
249    wftool.manage_addWorkflow(id=wfid,
250                              workflow_type='cps_workflow (Web-configurable workflow for CPS)')
251
252    wf = wftool[wfid]
253
254    for p in (View,
255              ModifyPortalContent,
256              ):
257        wf.addManagedPermission(p)
258
259    ###########################################################################
260    ###########################################################################
261
262    #                                  STATES
263
264    ###########################################################################
265    ###########################################################################
266
267    for s in ('work',
268              'closed'):
269        wf.states.addState(s)
270
271    ##########################################################################
272    #                                  WORK
273    ##########################################################################
274
275    s = wf.states.get('work')
276
277##    s.setPermission(View, 1, ('ChatPoster',))
278##    s.setPermission(ModifyPortalContent, 1, ('ChatModerator',))
279##    s.setPermission(chatReply, 1, ('ChatModerator', 'ChatGuest',))
280##    s.setPermission(chatPost, 1, ('ChatModerator', 'ChatPoster', 'ChatGuest',))
281##    s.setPermission(chatModerate, 1, ('ChatModerator',))
282
283    s.setInitialState('work')
284    s.setProperties(title='Work',
285                    description='',
286                    transitions=('create_content',
287                                 'cut_copy_paste',
288                                 'close',),)
289
290
291    ##########################################################################
292    #                                  CLOSED
293    ##########################################################################
294
295    s = wf.states.get('closed')
296
297##    s.setPermission(View, 1, ('ChatPoster',))
298##    s.setPermission(ModifyPortalContent, 1, ('ChatModerator',))
299##    s.setPermission(chatReply, 1, ('ChatModerator',))
300##    s.setPermission(chatPost, 1, ('ChatModerator',))
301##    s.setPermission(chatModerate, 1, ('ChatModerator',))
302
303    s.setProperties(title='Closed',
304                    description='',
305                    transitions=('unclose',
306                                 'cut_copy_paste',),)
307
308    ###########################################################################
309    ###########################################################################
310
311    #                               TRANSITIONS
312
313    ###########################################################################
314    ###########################################################################
315
316    for t in ('create',
317              'create_content',
318              'cut_copy_paste',
319              'close',
320              'unclose',):
321        wf.transitions.addTransition(t)
322
323
324    ###########################################################################
325    #                                 CREATE
326    ###########################################################################
327
328    t = wf.transitions.get('create')
329    t.setProperties(title='Initial creation',
330                    description='Intial transition like',
331                    new_state_id='work',
332                    transition_behavior=(TRANSITION_INITIAL_CREATE, ),
333                    clone_allowed_transitions=None,
334                    actbox_name='', actbox_category='workflow', actbox_url='',
335                    props={'guard_permissions':'',
336                           'guard_roles':'Manager; WorkspaceManager',
337                           'guard_expr':''},)
338
339    ###########################################################################
340    #                                  CREATE CONTENT
341    ###########################################################################
342
343    t = wf.transitions.get('create_content')
344    t.setProperties(title='Create content',
345                    description='Allow sub Object Create',
346                    new_state_id='work',
347                    transition_behavior=(TRANSITION_ALLOWSUB_CREATE,
348                                         TRANSITION_ALLOWSUB_CHECKOUT,),
349                    trigger_type=TRIGGER_USER_ACTION,
350                    actbox_name='New',
351                    actbox_category='',
352                    actbox_url='',
353                    props={'guard_permissions':'',
354                           'guard_roles':'Manager; WorkspaceManager; WorkspaceMember; WorkspaceReader',
355                           'guard_expr':''},)
356
357    ##########################################################################
358    #                                  CUT/COPY/PASTE
359    ##########################################################################
360
361    t = wf.transitions.get('cut_copy_paste')
362    t.setProperties(title='Cut/Copy/Paste',
363                    new_state_id='work',
364                    transition_behavior=(TRANSITION_ALLOWSUB_DELETE,
365                                         TRANSITION_ALLOWSUB_MOVE,
366                                         TRANSITION_ALLOWSUB_COPY),
367                    clone_allowed_transitions=None,
368                    trigger_type=TRIGGER_USER_ACTION,
369                    actbox_name='New',
370                    actbox_category='',
371                    actbox_url='',
372                    props={'guard_permissions':'',
373                           'guard_roles':'Manager; WorkspaceManager; WorkspaceMember',
374                           'guard_expr':''},)
375
376##    ##########################################################################
377##    #                                  CLOSE
378##    ##########################################################################
379##
380##    t = wf.transitions.get('close')
381##    t.setProperties(title='close',
382##                    new_state_id='closed',
383##                    transition_behavior=(),
384##                    clone_allowed_transitions=None,
385##                    trigger_type=TRIGGER_USER_ACTION,
386##                    actbox_name='label_chat_close',
387##                    actbox_category='workflow',
388##                    actbox_url='%(content_url)s/cps_chat_close',
389##                    props={'guard_permissions':'',
390##                           'guard_roles':'Manager; WorkspaceManager',
391##                           'guard_expr':''},)
392##
393##    ##########################################################################
394##    #                                  UNCLOSE
395##    ##########################################################################
396##
397##    t = wf.transitions.get('unclose')
398##    t.setProperties(title='unclose',
399##                    new_state_id='work',
400##                    transition_behavior=(),
401##                    clone_allowed_transitions=None,
402##                    trigger_type=TRIGGER_USER_ACTION,
403##                    actbox_name='label_chat_unclose',
404##                    actbox_category='workflow',
405##                    actbox_url='%(content_url)s/cps_chat_unclose',
406##                    props={'guard_permissions':'',
407##                           'guard_roles':'Manager; WorkspaceManager; ChatModerator',
408##                           'guard_expr':''},)
409
410    ################################################################
411    #                 VARIABLES
412    ################################################################
413
414    for v in ('action',
415              'actor',
416              'comments',
417              'review_history',
418              'time',
419              'dest_container',
420              ):
421        wf.variables.addVariable(v)
422
423
424    wf.variables.setStateVar('review_state')
425
426    vdef = wf.variables['action']
427    vdef.setProperties(description='The last transition',
428                       default_expr='transition/getId|nothing',
429                       for_status=1, update_always=1)
430
431    vdef = wf.variables['actor']
432    vdef.setProperties(description='The ID of the user who performed '
433                       'the last transition',
434                       default_expr='user/getId',
435                       for_status=1, update_always=1)
436
437    vdef = wf.variables['comments']
438    vdef.setProperties(description='Comments about the last transition',
439                       default_expr="python:state_change.kwargs.get('comment', '')",
440                       for_status=1, update_always=1)
441
442    vdef = wf.variables['review_history']
443    vdef.setProperties(description='Provides access to workflow history',
444                       default_expr="state_change/getHistory",
445                       props={'guard_permissions':'',
446                              'guard_roles':'Manager; WorkspaceManager; WorkspaceMember; WorkspaceReader; Member',
447                              'guard_expr':''})
448
449    vdef = wf.variables['time']
450    vdef.setProperties(description='Time of the last transition',
451                       default_expr="state_change/getDateTime",
452                       for_status=1, update_always=1)
453
454    vdef = wf.variables['dest_container']
455    vdef.setProperties(description='Destination container for the last paste/publish',
456                       default_expr="python:state_change.kwargs.get('dest_container', '')",
457                       for_status=1, update_always=1)
Note: See TracBrowser for help on using the repository browser.