# # # Generated by dumpDCWorkflow.py written by Sebastien Bigaret, # Scripts inline by Russ Ferriday, russf@topia.com # # Original workflow id/title: revision_workflow/Revision Workflow # Date: 2005/06/23 07:48:49.719 GMT+2 # # # The following scripts have been detected: # - mail2admin (Script (Python)) # """ Programmatically creates a workflow type """ __version__ = "$Revision: 1.1.1.1 $"[11:-2] from Products.CMFCore.WorkflowTool import addWorkflowFactory from Products.DCWorkflow.DCWorkflow import DCWorkflowDefinition def setupRevision_workflow(wf): "..." wf.setProperties(title='Revision Workflow') for s in ['deleted', 'private', 'visible', 'published', 'pending', 'revision']: wf.states.addState(s) for t in ['hide', 'show', 're-submit', 'submit', 'publish', 'reject', 'retract', 'revise', 'delete']: wf.transitions.addTransition(t) for v in ['action', 'review_history', 'actor', 'comments', 'time']: wf.variables.addVariable(v) for l in ['revision_queue', 'deleted_queue', 'reviewer_queue']: wf.worklists.addWorklist(l) for p in ('Access contents information', 'Modify portal content', 'View', 'Change portal events'): wf.addManagedPermission(p) from Products.PythonScripts.PythonScript import manage_addPythonScript for p in ['mail2admin']: manage_addPythonScript(wf.scripts, p) ## Initial State wf.states.setInitialState('visible') ## States initialization sdef = wf.states['deleted'] sdef.setProperties(title="""""", transitions=('re-submit',)) sdef.setPermission('Access contents information', 0, ['Manager', 'Owner']) sdef.setPermission('Modify portal content', 0, ['Manager', 'Owner']) sdef.setPermission('View', 0, ['Manager', 'Owner']) sdef.setPermission('Change portal events', 0, ['Manager', 'Owner']) sdef = wf.states['private'] sdef.setProperties(title="""Visible and editable only by owner""", transitions=('show',)) sdef.setPermission('Access contents information', 0, ['Manager', 'Owner']) sdef.setPermission('Modify portal content', 0, ['Manager', 'Owner']) sdef.setPermission('View', 0, ['Manager', 'Owner']) sdef.setPermission('Change portal events', 0, ['Manager', 'Owner']) sdef = wf.states['visible'] sdef.setProperties(title="""Visible but not published""", transitions=('delete', 'hide', 'publish', 'submit')) sdef.setPermission('Access contents information', 1, ['Anonymous', 'Manager', 'Reviewer']) sdef.setPermission('Modify portal content', 0, ['Manager', 'Owner']) sdef.setPermission('View', 1, ['Anonymous', 'Manager', 'Reviewer']) sdef.setPermission('Change portal events', 0, ['Manager', 'Owner']) sdef = wf.states['published'] sdef.setProperties(title="""Public""", transitions=('delete', 'reject', 'retract', 'revise')) sdef.setPermission('Access contents information', 1, ['Anonymous', 'Manager']) sdef.setPermission('Modify portal content', 0, ['Manager']) sdef.setPermission('View', 1, ['Anonymous', 'Manager']) sdef.setPermission('Change portal events', 0, ['Manager']) sdef = wf.states['pending'] sdef.setProperties(title="""Waiting for reviewer""", transitions=('publish', 'reject', 'retract', 'revise')) sdef.setPermission('Access contents information', 1, ['Manager', 'Owner', 'Reviewer']) sdef.setPermission('Modify portal content', 0, ['Manager', 'Reviewer']) sdef.setPermission('View', 1, ['Manager', 'Owner', 'Reviewer']) sdef.setPermission('Change portal events', 0, ['Manager', 'Reviewer']) sdef = wf.states['revision'] sdef.setProperties(title="""Waiting for member""", transitions=('delete', 'publish', 're-submit', 'retract')) sdef.setPermission('Access contents information', 1, ['Anonymous', 'Manager', 'Reviewer']) sdef.setPermission('Modify portal content', 0, ['Manager', 'Owner']) sdef.setPermission('View', 1, ['Anonymous', 'Manager', 'Reviewer']) sdef.setPermission('Change portal events', 0, ['Manager', 'Owner']) ## Scripts Installation scrdef = wf.scripts['mail2admin'] scrdef.ZPythonScript_edit('', """## Script (Python) "mail2admin" ##bind container=container ##bind context=context ##bind namespace= ##bind script=script ##bind subpath=traverse_subpath ##parameters=state_change ##title= ## # the objects we need object = state_change.object mship = context.portal_membership mhost = context.MailHost prop = context.portal_properties # the message format, %s will be filled in from data message = From: %s To: %s Subject: New item submitted for approval - %s %s URL: %s msg = message % ( prop.email_from_address, prop.email_from_address, object.TitleOrId(), object.Description(), object.absolute_url() ) mhost.send(msg) """.replace("", '"""')) ## Transitions initialization tdef = wf.transitions['hide'] tdef.setProperties(title="""Member makes content private""", new_state_id="""private""", trigger_type=1, script_name="""""", after_script_name="""""", actbox_name="""Make private""", actbox_url="""%(content_url)s/content_hide_form""", actbox_category="""workflow""", props={'guard_roles': 'Owner'}, ) tdef = wf.transitions['show'] tdef.setProperties(title="""Member makes content visible""", new_state_id="""visible""", trigger_type=1, script_name="""""", after_script_name="""""", actbox_name="""Make visible""", actbox_url="""%(content_url)s/content_show_form""", actbox_category="""workflow""", props={'guard_roles': 'Owner'}, ) tdef = wf.transitions['re-submit'] tdef.setProperties(title="""Member requests re-publishing""", new_state_id="""pending""", trigger_type=1, script_name="""""", after_script_name="""mail2admin""", actbox_name="""Re-submit""", actbox_url="""%(content_url)s/content_submit_form""", actbox_category="""workflow""", props={'guard_permissions': 'Request review'}, ) tdef = wf.transitions['submit'] tdef.setProperties(title="""Member requests publishing""", new_state_id="""pending""", trigger_type=1, script_name="""""", after_script_name="""mail2admin""", actbox_name="""Submit""", actbox_url="""%(content_url)s/content_submit_form""", actbox_category="""workflow""", props={'guard_permissions': 'Request review'}, ) tdef = wf.transitions['publish'] tdef.setProperties(title="""Reviewer publishes content""", new_state_id="""published""", trigger_type=1, script_name="""""", after_script_name="""""", actbox_name="""Publish""", actbox_url="""%(content_url)s/content_publish_form""", actbox_category="""workflow""", props={'guard_permissions': 'Review portal content'}, ) tdef = wf.transitions['reject'] tdef.setProperties(title="""Reviewer rejects submission""", new_state_id="""revision""", trigger_type=1, script_name="""""", after_script_name="""""", actbox_name="""Reject""", actbox_url="""%(content_url)s/content_reject_form""", actbox_category="""workflow""", props={'guard_permissions': 'Review portal content'}, ) tdef = wf.transitions['retract'] tdef.setProperties(title="""Reviewer retracts submission""", new_state_id="""visible""", trigger_type=1, script_name="""""", after_script_name="""""", actbox_name="""Retract""", actbox_url="""%(content_url)s/content_retract_form""", actbox_category="""workflow""", props={'guard_permissions': 'Review portal content'}, ) tdef = wf.transitions['revise'] tdef.setProperties(title="""Member revises submission""", new_state_id="""revision""", trigger_type=1, script_name="""""", after_script_name="""""", actbox_name="""Revise""", actbox_url="""""", actbox_category="""workflow""", props={'guard_permissions': 'Request review'}, ) tdef = wf.transitions['delete'] tdef.setProperties(title="""Member requests deletion""", new_state_id="""deleted""", trigger_type=1, script_name="""""", after_script_name="""mail2admin""", actbox_name="""Delete""", actbox_url="""""", actbox_category="""workflow""", props={'guard_permissions': 'Request review'}, ) ## State Variable wf.variables.setStateVar('review_state') ## Variables initialization vdef = wf.variables['action'] vdef.setProperties(description="""The last transition""", default_value="""""", default_expr="""transition/getId|nothing""", for_catalog=0, for_status=1, update_always=1, props=None) vdef = wf.variables['review_history'] vdef.setProperties(description="""Provides access to workflow history""", default_value="""""", default_expr="""state_change/getHistory""", for_catalog=0, for_status=0, update_always=0, props={'guard_permissions': 'Request review; Review portal content'}) vdef = wf.variables['actor'] vdef.setProperties(description="""The ID of the user who performed the last transition""", default_value="""""", default_expr="""user/getId""", for_catalog=0, for_status=1, update_always=1, props=None) vdef = wf.variables['comments'] vdef.setProperties(description="""Comments about the last transition""", default_value="""""", default_expr="""python:state_change.kwargs.get('comment', '')""", for_catalog=0, for_status=1, update_always=1, props=None) vdef = wf.variables['time'] vdef.setProperties(description="""Time of the last transition""", default_value="""""", default_expr="""state_change/getDateTime""", for_catalog=0, for_status=1, update_always=1, props=None) ## Worklists Initialization ldef = wf.worklists['revision_queue'] ldef.setProperties(description="""Revision monitor""", actbox_name="""In revision (%(count)d)""", actbox_url="""%(portal_url)s/search?review_state=revision""", actbox_category="""global""", props={'guard_permissions': 'Review portal content', 'var_match_review_state': 'revision'}) ldef = wf.worklists['deleted_queue'] ldef.setProperties(description="""Deletion monitor""", actbox_name="""Deleted (%(count)d)""", actbox_url="""%(portal_url)s/search?review_state=deleted""", actbox_category="""global""", props={'guard_permissions': 'Review portal content', 'var_match_review_state': 'deleted'}) ldef = wf.worklists['reviewer_queue'] ldef.setProperties(description="""Revision monitor""", actbox_name="""Pending (%(count)d)""", actbox_url="""%(portal_url)s/search?review_state=pending""", actbox_category="""global""", props={'guard_permissions': 'Review portal content', 'var_match_review_state': 'pending'}) def createRevision_workflow(id): "..." ob = DCWorkflowDefinition(id) setupRevision_workflow(ob) return ob addWorkflowFactory(createRevision_workflow, id='revision_workflow', title='Revision Workflow')