source: WAeUP_CMS/trunk/skins/WAEUP/revision_workflow.py @ 3810

Last change on this file since 3810 was 35, checked in by Henrik Bettermann, 19 years ago
File size: 13.4 KB
Line 
1#
2#
3# Generated by dumpDCWorkflow.py written by Sebastien Bigaret,
4# Scripts inline by Russ Ferriday, russf@topia.com
5#
6# Original workflow id/title: revision_workflow/Revision Workflow
7# Date: 2005/06/23 07:48:49.719 GMT+2
8#
9#
10# The following scripts have been detected:
11# - mail2admin (Script (Python))
12#
13"""
14Programmatically creates a workflow type
15"""
16__version__ = "$Revision: 1.1.1.1 $"[11:-2]
17
18from Products.CMFCore.WorkflowTool import addWorkflowFactory
19
20from Products.DCWorkflow.DCWorkflow import DCWorkflowDefinition
21
22def setupRevision_workflow(wf):
23    "..."
24    wf.setProperties(title='Revision Workflow')
25
26    for s in ['deleted', 'private', 'visible', 'published', 'pending', 'revision']:
27        wf.states.addState(s)
28    for t in ['hide', 'show', 're-submit', 'submit', 'publish', 'reject', 'retract', 'revise', 'delete']:
29        wf.transitions.addTransition(t)
30    for v in ['action', 'review_history', 'actor', 'comments', 'time']:
31        wf.variables.addVariable(v)
32    for l in ['revision_queue', 'deleted_queue', 'reviewer_queue']:
33        wf.worklists.addWorklist(l)
34    for p in ('Access contents information', 'Modify portal content', 'View', 'Change portal events'):
35        wf.addManagedPermission(p)
36    from Products.PythonScripts.PythonScript import manage_addPythonScript
37    for p in ['mail2admin']:
38        manage_addPythonScript(wf.scripts, p)
39
40
41
42    ## Initial State
43    wf.states.setInitialState('visible')
44
45    ## States initialization
46    sdef = wf.states['deleted']
47    sdef.setProperties(title="""""",
48                       transitions=('re-submit',))
49    sdef.setPermission('Access contents information', 0, ['Manager', 'Owner'])
50    sdef.setPermission('Modify portal content', 0, ['Manager', 'Owner'])
51    sdef.setPermission('View', 0, ['Manager', 'Owner'])
52    sdef.setPermission('Change portal events', 0, ['Manager', 'Owner'])
53
54    sdef = wf.states['private']
55    sdef.setProperties(title="""Visible and editable only by owner""",
56                       transitions=('show',))
57    sdef.setPermission('Access contents information', 0, ['Manager', 'Owner'])
58    sdef.setPermission('Modify portal content', 0, ['Manager', 'Owner'])
59    sdef.setPermission('View', 0, ['Manager', 'Owner'])
60    sdef.setPermission('Change portal events', 0, ['Manager', 'Owner'])
61
62    sdef = wf.states['visible']
63    sdef.setProperties(title="""Visible but not published""",
64                       transitions=('delete', 'hide', 'publish', 'submit'))
65    sdef.setPermission('Access contents information', 1, ['Anonymous', 'Manager', 'Reviewer'])
66    sdef.setPermission('Modify portal content', 0, ['Manager', 'Owner'])
67    sdef.setPermission('View', 1, ['Anonymous', 'Manager', 'Reviewer'])
68    sdef.setPermission('Change portal events', 0, ['Manager', 'Owner'])
69
70    sdef = wf.states['published']
71    sdef.setProperties(title="""Public""",
72                       transitions=('delete', 'reject', 'retract', 'revise'))
73    sdef.setPermission('Access contents information', 1, ['Anonymous', 'Manager'])
74    sdef.setPermission('Modify portal content', 0, ['Manager'])
75    sdef.setPermission('View', 1, ['Anonymous', 'Manager'])
76    sdef.setPermission('Change portal events', 0, ['Manager'])
77
78    sdef = wf.states['pending']
79    sdef.setProperties(title="""Waiting for reviewer""",
80                       transitions=('publish', 'reject', 'retract', 'revise'))
81    sdef.setPermission('Access contents information', 1, ['Manager', 'Owner', 'Reviewer'])
82    sdef.setPermission('Modify portal content', 0, ['Manager', 'Reviewer'])
83    sdef.setPermission('View', 1, ['Manager', 'Owner', 'Reviewer'])
84    sdef.setPermission('Change portal events', 0, ['Manager', 'Reviewer'])
85
86    sdef = wf.states['revision']
87    sdef.setProperties(title="""Waiting for member""",
88                       transitions=('delete', 'publish', 're-submit', 'retract'))
89    sdef.setPermission('Access contents information', 1, ['Anonymous', 'Manager', 'Reviewer'])
90    sdef.setPermission('Modify portal content', 0, ['Manager', 'Owner'])
91    sdef.setPermission('View', 1, ['Anonymous', 'Manager', 'Reviewer'])
92    sdef.setPermission('Change portal events', 0, ['Manager', 'Owner'])
93
94    ## Scripts Installation
95    scrdef = wf.scripts['mail2admin']
96    scrdef.ZPythonScript_edit('',
97    """## Script (Python) "mail2admin"
98##bind container=container
99##bind context=context
100##bind namespace=
101##bind script=script
102##bind subpath=traverse_subpath
103##parameters=state_change
104##title=
105##
106# the objects we need
107object = state_change.object
108mship = context.portal_membership
109mhost = context.MailHost
110prop = context.portal_properties
111
112# the message format, %s will be filled in from data
113message = <com.topia.constants.tquote.proxy>
114From: %s
115To: %s
116Subject: New item submitted for approval - %s
117
118%s
119
120URL: %s
121<com.topia.constants.tquote.proxy>
122
123msg = message % (
124     prop.email_from_address,
125     prop.email_from_address,
126     object.TitleOrId(),
127     object.Description(),
128     object.absolute_url()
129     )
130mhost.send(msg)
131""".replace("<com.topia.constants.tquote.proxy>", '"""'))
132
133
134    ## Transitions initialization
135    tdef = wf.transitions['hide']
136    tdef.setProperties(title="""Member makes content private""",
137                       new_state_id="""private""",
138                       trigger_type=1,
139                       script_name="""""",
140                       after_script_name="""""",
141                       actbox_name="""Make private""",
142                       actbox_url="""%(content_url)s/content_hide_form""",
143                       actbox_category="""workflow""",
144                       props={'guard_roles': 'Owner'},
145                       )
146
147    tdef = wf.transitions['show']
148    tdef.setProperties(title="""Member makes content visible""",
149                       new_state_id="""visible""",
150                       trigger_type=1,
151                       script_name="""""",
152                       after_script_name="""""",
153                       actbox_name="""Make visible""",
154                       actbox_url="""%(content_url)s/content_show_form""",
155                       actbox_category="""workflow""",
156                       props={'guard_roles': 'Owner'},
157                       )
158
159    tdef = wf.transitions['re-submit']
160    tdef.setProperties(title="""Member requests re-publishing""",
161                       new_state_id="""pending""",
162                       trigger_type=1,
163                       script_name="""""",
164                       after_script_name="""mail2admin""",
165                       actbox_name="""Re-submit""",
166                       actbox_url="""%(content_url)s/content_submit_form""",
167                       actbox_category="""workflow""",
168                       props={'guard_permissions': 'Request review'},
169                       )
170
171    tdef = wf.transitions['submit']
172    tdef.setProperties(title="""Member requests publishing""",
173                       new_state_id="""pending""",
174                       trigger_type=1,
175                       script_name="""""",
176                       after_script_name="""mail2admin""",
177                       actbox_name="""Submit""",
178                       actbox_url="""%(content_url)s/content_submit_form""",
179                       actbox_category="""workflow""",
180                       props={'guard_permissions': 'Request review'},
181                       )
182
183    tdef = wf.transitions['publish']
184    tdef.setProperties(title="""Reviewer publishes content""",
185                       new_state_id="""published""",
186                       trigger_type=1,
187                       script_name="""""",
188                       after_script_name="""""",
189                       actbox_name="""Publish""",
190                       actbox_url="""%(content_url)s/content_publish_form""",
191                       actbox_category="""workflow""",
192                       props={'guard_permissions': 'Review portal content'},
193                       )
194
195    tdef = wf.transitions['reject']
196    tdef.setProperties(title="""Reviewer rejects submission""",
197                       new_state_id="""revision""",
198                       trigger_type=1,
199                       script_name="""""",
200                       after_script_name="""""",
201                       actbox_name="""Reject""",
202                       actbox_url="""%(content_url)s/content_reject_form""",
203                       actbox_category="""workflow""",
204                       props={'guard_permissions': 'Review portal content'},
205                       )
206
207    tdef = wf.transitions['retract']
208    tdef.setProperties(title="""Reviewer retracts submission""",
209                       new_state_id="""visible""",
210                       trigger_type=1,
211                       script_name="""""",
212                       after_script_name="""""",
213                       actbox_name="""Retract""",
214                       actbox_url="""%(content_url)s/content_retract_form""",
215                       actbox_category="""workflow""",
216                       props={'guard_permissions': 'Review portal content'},
217                       )
218
219    tdef = wf.transitions['revise']
220    tdef.setProperties(title="""Member revises submission""",
221                       new_state_id="""revision""",
222                       trigger_type=1,
223                       script_name="""""",
224                       after_script_name="""""",
225                       actbox_name="""Revise""",
226                       actbox_url="""""",
227                       actbox_category="""workflow""",
228                       props={'guard_permissions': 'Request review'},
229                       )
230
231    tdef = wf.transitions['delete']
232    tdef.setProperties(title="""Member requests deletion""",
233                       new_state_id="""deleted""",
234                       trigger_type=1,
235                       script_name="""""",
236                       after_script_name="""mail2admin""",
237                       actbox_name="""Delete""",
238                       actbox_url="""""",
239                       actbox_category="""workflow""",
240                       props={'guard_permissions': 'Request review'},
241                       )
242
243    ## State Variable
244    wf.variables.setStateVar('review_state')
245
246    ## Variables initialization
247    vdef = wf.variables['action']
248    vdef.setProperties(description="""The last transition""",
249                       default_value="""""",
250                       default_expr="""transition/getId|nothing""",
251                       for_catalog=0,
252                       for_status=1,
253                       update_always=1,
254                       props=None)
255
256    vdef = wf.variables['review_history']
257    vdef.setProperties(description="""Provides access to workflow history""",
258                       default_value="""""",
259                       default_expr="""state_change/getHistory""",
260                       for_catalog=0,
261                       for_status=0,
262                       update_always=0,
263                       props={'guard_permissions': 'Request review; Review portal content'})
264
265    vdef = wf.variables['actor']
266    vdef.setProperties(description="""The ID of the user who performed the last transition""",
267                       default_value="""""",
268                       default_expr="""user/getId""",
269                       for_catalog=0,
270                       for_status=1,
271                       update_always=1,
272                       props=None)
273
274    vdef = wf.variables['comments']
275    vdef.setProperties(description="""Comments about the last transition""",
276                       default_value="""""",
277                       default_expr="""python:state_change.kwargs.get('comment', '')""",
278                       for_catalog=0,
279                       for_status=1,
280                       update_always=1,
281                       props=None)
282
283    vdef = wf.variables['time']
284    vdef.setProperties(description="""Time of the last transition""",
285                       default_value="""""",
286                       default_expr="""state_change/getDateTime""",
287                       for_catalog=0,
288                       for_status=1,
289                       update_always=1,
290                       props=None)
291
292    ## Worklists Initialization
293    ldef = wf.worklists['revision_queue']
294    ldef.setProperties(description="""Revision monitor""",
295                       actbox_name="""In revision (%(count)d)""",
296                       actbox_url="""%(portal_url)s/search?review_state=revision""",
297                       actbox_category="""global""",
298                       props={'guard_permissions': 'Review portal content', 'var_match_review_state': 'revision'})
299
300    ldef = wf.worklists['deleted_queue']
301    ldef.setProperties(description="""Deletion monitor""",
302                       actbox_name="""Deleted (%(count)d)""",
303                       actbox_url="""%(portal_url)s/search?review_state=deleted""",
304                       actbox_category="""global""",
305                       props={'guard_permissions': 'Review portal content', 'var_match_review_state': 'deleted'})
306
307    ldef = wf.worklists['reviewer_queue']
308    ldef.setProperties(description="""Revision monitor""",
309                       actbox_name="""Pending (%(count)d)""",
310                       actbox_url="""%(portal_url)s/search?review_state=pending""",
311                       actbox_category="""global""",
312                       props={'guard_permissions': 'Review portal content', 'var_match_review_state': 'pending'})
313
314
315def createRevision_workflow(id):
316    "..."
317    ob = DCWorkflowDefinition(id)
318    setupRevision_workflow(ob)
319    return ob
320
321addWorkflowFactory(createRevision_workflow,
322                   id='revision_workflow',
323                   title='Revision Workflow')
324
325
326
Note: See TracBrowser for help on using the repository browser.