Logo Search packages:      
Sourcecode: zope-cmfmember version File versions  Download package

MemberAutoWorkflow.py

# 
#
# Generated by dumpDCWorkflow.py written by Sebastien Bigaret
# Original workflow id/title: member_auto_workflow/Portal Member Workflow: Automatic Approval
# Date: 2004/07/21 13:08:32.343 GMT-7
#
# WARNING: this dumps does NOT contain any scripts you might have added to
# the workflow, IT IS YOUR RESPONSABILITY TO MAKE BACKUPS FOR THESE SCRIPTS.
#
# The following scripts have been detected and should be backed up:
# - autoRegister (External Method)
# - enable (External Method)
# - makePublic (External Method)
# - disable (External Method)
# - makePrivate (External Method)
# - register (External Method)
# 
"""
Programmatically creates a workflow type
"""
__version__ = "$Revision: 1.8.2.2 $"[11:-2]

from Products.CMFCore.WorkflowTool import addWorkflowFactory
from Products.DCWorkflow.DCWorkflow import DCWorkflowDefinition

def setupMember_auto_workflow(wf):
    "..."
    wf.setProperties(title='Portal Member Workflow: Automatic Approval')

    for s in ['disabled', 'new', 'public', 'private','new_private']:
        wf.states.addState(s)
    for t in ['auto_register', 'enable_public', 'migrate', 'disable', 'register_wrapped_user', 'make_private', 'trigger', 'make_public', 'enable_private', 'import_fail']:
        wf.transitions.addTransition(t)
    for v in ['action', 'review_history', 'actor', 'comments', 'time']:
        wf.variables.addVariable(v)
    for l in ['reviewer_queue']:
        wf.worklists.addWorklist(l)
    for p in ('CMFMember: Register member', 'CMFMember: Edit member id', 'Set own properties', 'Set own password', 'Manage users', 'View', 'Modify portal content', 'Mail forgotten password'):
        wf.addManagedPermission(p)
        

    ## Initial State
    wf.states.setInitialState('new')

    ## States initialization
    sdef = wf.states['disabled']
    sdef.setProperties(title="""Disabled""",
                       transitions=('enable_private', 'enable_public'))
    sdef.setPermission('CMFMember: Register member', 0, ['Manager'])
    sdef.setPermission('CMFMember: Edit member id', 0, ['Manager'])
    sdef.setPermission('Set own properties', 0, ['Manager'])
    sdef.setPermission('Set own password', 0, ['Manager'])
    sdef.setPermission('Manage users', 0, ['Manager'])
    sdef.setPermission('View', 0, ['Manager'])
    sdef.setPermission('Modify portal content', 0, ['Manager'])
    sdef.setPermission('Mail forgotten password', 0, [])

    sdef = wf.states['new']
    sdef.setProperties(title="""Newly created member""",
                       transitions=('auto_register', 'import_fail', 'migrate', 'register_wrapped_user', 'trigger'))
    sdef.setPermission('CMFMember: Register member', 0, ['Anonymous', 'Manager'])
    sdef.setPermission('CMFMember: Edit member id', 0, ['Anonymous', 'Manager'])
    sdef.setPermission('Set own properties', 0, ['Anonymous', 'Manager'])
    sdef.setPermission('Set own password', 0, ['Anonymous', 'Manager'])
    sdef.setPermission('Manage users', 0, ['Manager'])
    sdef.setPermission('View', 0, ['Anonymous', 'Manager'])
    sdef.setPermission('Modify portal content', 0, ['Anonymous'])
    sdef.setPermission('Mail forgotten password', 0, ['Manager'])

    sdef = wf.states['new_private']
    sdef.setProperties(title="""Newly created member""",
                       transitions=('auto_register', 'migrate', 'register_wrapped_user', 'trigger'))
    sdef.setPermission('CMFMember: Register member', 0, ['Manager'])
    sdef.setPermission('CMFMember: Edit member id', 0, ['Manager'])
    sdef.setPermission('Set own properties', 0, [ 'Manager'])
    sdef.setPermission('Set own password', 0, [ 'Manager'])
    sdef.setPermission('Manage users', 0, ['Manager'])
    sdef.setPermission('View', 0, ['Manager'])
    sdef.setPermission('Modify portal content', 0, ['Manager'])
    sdef.setPermission('Mail forgotten password', 0, ['Manager'])

    sdef = wf.states['public']
    sdef.setProperties(title="""Registered user, public profile""",
                       transitions=('make_private', 'disable'))
    sdef.setPermission('CMFMember: Register member', 0, [])
    sdef.setPermission('CMFMember: Edit member id', 0, [])
    sdef.setPermission('Set own properties', 0, ['Manager', 'Owner'])
    sdef.setPermission('Set own password', 0, ['Manager', 'Owner'])
    sdef.setPermission('Manage users', 0, ['Manager'])
    sdef.setPermission('View', 0, ['Anonymous', 'Authenticated', 'Manager', 'Member', 'Owner'])
    sdef.setPermission('Modify portal content', 0, ['Manager', 'Owner'])
    sdef.setPermission('Mail forgotten password', 0, ['Anonymous','Manager', 'Owner'])

    sdef = wf.states['private']
    sdef.setProperties(title="""Registered user, private profile""",
                       transitions=('make_public', 'disable'))
    sdef.setPermission('CMFMember: Register member', 0, [])
    sdef.setPermission('CMFMember: Edit member id', 0, [])
    sdef.setPermission('Set own properties', 0, ['Manager', 'Owner'])
    sdef.setPermission('Set own password', 0, ['Manager', 'Owner'])
    sdef.setPermission('Manage users', 0, ['Manager'])
    sdef.setPermission('View', 0, ['Manager', 'Owner'])
    sdef.setPermission('Modify portal content', 0, ['Manager', 'Owner'])
    sdef.setPermission('Mail forgotten password', 0, ['Anonymous', 'Manager', 'Owner'])

    
    ## Transitions initialization
    tdef = wf.transitions['auto_register']
    tdef.setProperties(title="""Begin auto registration of member""",
                       new_state_id="""public""",
                       trigger_type=0,
                       script_name="""autoRegister""",
                       after_script_name="""makePublic""",
                       actbox_name="""Automatically approve member""",
                       actbox_url="""""",
                       actbox_category="""workflow""",
                       props={'guard_expr': 'here/isValid', 'guard_permissions': 'CMFMember: Register member'},
                       )

    tdef = wf.transitions['enable_public']
    tdef.setProperties(title="""Re-enable member""",
                       new_state_id="""public""",
                       trigger_type=1,
                       script_name="""""",
                       after_script_name="""enable""",
                       actbox_name="""Re-enable member""",
                       actbox_url="""""",
                       actbox_category="""workflow""",
                       props={'guard_expr': "python:getattr(here,'old_state',None) == 'public'", 'guard_permissions': 'Manage users'},
                       )

    tdef = wf.transitions['migrate']
    tdef.setProperties(title="""Migrate from pre-1.0 CMF MemberData""",
                       new_state_id="""public""",
                       trigger_type=1,
                       script_name="""""",
                       after_script_name="""makePublic""",
                       actbox_name="""Migrate from pre-1.0 CMF MemberData""",
                       actbox_url="""""",
                       actbox_category="""workflow""",
                       props={'guard_roles': 'Manager'},
                       )

    tdef = wf.transitions['disable']
    tdef.setProperties(title="""Disable member""",
                       new_state_id="""disabled""",
                       trigger_type=1,
                       script_name="""disable""",
                       after_script_name="""""",
                       actbox_name="""Disable member""",
                       actbox_url="""""",
                       actbox_category="""workflow""",
                       props={'guard_permissions': 'Manage users'},
                       )

    tdef = wf.transitions['register_wrapped_user']
    tdef.setProperties(title="""Automatically register a wrapped Member""",
                       new_state_id="""public""",
                       trigger_type=0,
                       script_name="""""",
                       after_script_name="""makePublic""",
                       actbox_name="""Register wrapped user""",
                       actbox_url="""""",
                       actbox_category="""workflow""",
                       props={'guard_expr': 'python:here.hasUser()', 'guard_roles': 'Owner'},
                       )

    tdef = wf.transitions['make_private']
    tdef.setProperties(title="""Make member profile private""",
                       new_state_id="""private""",
                       trigger_type=1,
                       script_name="""""",
                       after_script_name="""makePrivate""",
                       actbox_name="""Make member profile private""",
                       actbox_url="""""",
                       actbox_category="""workflow""",
                       props={'guard_roles': 'Owner; Manager'},
                       )

    tdef = wf.transitions['trigger']
    tdef.setProperties(title="""Trigger automatic transitions""",
                       new_state_id="""""",
                       trigger_type=1,
                       script_name="""""",
                       after_script_name="""""",
                       actbox_name="""Trigger automatic transitions""",
                       actbox_url="""""",
                       actbox_category="""workflow""",
                       props=None,
                       )

    tdef = wf.transitions['make_public']
    tdef.setProperties(title="""Make member profile public""",
                       new_state_id="""public""",
                       trigger_type=1,
                       script_name="""""",
                       after_script_name="""makePublic""",
                       actbox_name="""Make member profile public""",
                       actbox_url="""""",
                       actbox_category="""workflow""",
                       props={'guard_roles': 'Owner; Manager'},
                       )

    tdef = wf.transitions['enable_private']
    tdef.setProperties(title="""Re-enable member""",
                       new_state_id="""private""",
                       trigger_type=1,
                       script_name="""""",
                       after_script_name="""enable""",
                       actbox_name="""Re-enable member""",
                       actbox_url="""""",
                       actbox_category="""workflow""",
                       props={'guard_expr': "python:getattr(here,'old_state',None) == 'private'", 'guard_permissions': 'Manage users'},
                       )

    tdef = wf.transitions['import_fail']
    tdef.setProperties(title="""failed import""",
                       new_state_id="""import_fail""",
                       trigger_type=2,
                       script_name="""""",
                       after_script_name="""""",
                       actbox_name="""import_fail""",
                       actbox_url="""""",
                       actbox_category="""workflow""",
                       props={},
                       )

    ## 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['reviewer_queue']
    ldef.setProperties(description="""Reviewer tasks""",
                       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 createMember_auto_workflow(id):
    "..."
    ob = DCWorkflowDefinition(id)
    setupMember_auto_workflow(ob)
    return ob

addWorkflowFactory(createMember_auto_workflow,
                   id='member_auto_workflow',
                   title='Portal Member Workflow: Automatic Approval')

    

Generated by  Doxygen 1.6.0   Back to index