def createPatchWorkflow(id):
    wf=DCWorkflowDefinition(id)
    wf.setProperties(title='Patch Workflow [Rhaptos]')

    for s in ('created', 'submitted', 'applied', 'rejected'):
        wf.states.addState(s)
    for t in ('submit', 'apply', 'reject'):
        wf.transitions.addTransition(t)
    for v in ('action', 'actor', 'comments', 'review_history', 'time'):
        wf.variables.addVariable(v)

    wf.states.setInitialState('created')

    # Configure states
    sdef = wf.states['created']
    sdef.setProperties(title='Newly created', transitions=('submit',))

    sdef = wf.states['submitted']
    sdef.setProperties(title='Submitted and pending review', transitions=('apply', 'reject',),
                       description='Waiting on a reviewer to accept the patch and apply it to the correct content')

    sdef = wf.states['applied']
    sdef.setProperties(title='Accepted by a reviwer',
                       description='The patch has been accepted and applied to a working copy of the content item.  The changes will not be public, however, until the item is published')

    sdef = wf.states['rejected']
    sdef.setProperties(title='Rejected by a reviwer',
                       description='The changes have been rejected by a reviewer.')
        
    # Configure transitions
    tdef = wf.transitions['apply']
    tdef.setProperties(title='Reviewer applies changes', new_state_id='applied')
                       
    tdef = wf.transitions['reject']
    tdef.setProperties(title='Reviewer rejects changes', new_state_id='rejected')

    tdef = wf.transitions['submit']
    tdef.setProperties(title='Submit for review', new_state_id='submitted')

    # Configure variables
    wf.variables.setStateVar('review_state')

    vdef = wf.variables['action']
    vdef.setProperties(description='The last transition',
                       default_expr='transition/getId|nothing',
                       for_status=1, update_always=1)

    vdef = wf.variables['actor']
    vdef.setProperties(description='The ID of the user who performed '
                       'the last transition',
                       default_expr='user/getId',
                       for_status=1, update_always=1)

    vdef = wf.variables['comments']
    vdef.setProperties(description='Comments about the last transition',
                       default_expr="python:state_change.kwargs.get('comment', '')",
                       for_status=1, update_always=1)

    vdef = wf.variables['review_history']
    vdef.setProperties(description='Provides access to workflow history',
                       default_expr="state_change/getHistory",
                       props={'guard_permissions': View})

    vdef = wf.variables['time']
    vdef.setProperties(description='Time of the last transition',
                       default_expr="state_change/getDateTime",
                       for_status=1, update_always=1)


    configureEventPermissions(wf)
    return wf
Ejemplo n.º 2
0
def createElementWorkflow(id):
    ob=DCWorkflowDefinition(id)
    setupElementWorkflow(ob)
    ob.setProperties(title=ECMCE_WORKFLOW_TITLE)
    return ob
def createPatchWorkflow(id):
    wf = DCWorkflowDefinition(id)
    wf.setProperties(title='Patch Workflow [Rhaptos]')

    for s in ('created', 'submitted', 'applied', 'rejected'):
        wf.states.addState(s)
    for t in ('submit', 'apply', 'reject'):
        wf.transitions.addTransition(t)
    for v in ('action', 'actor', 'comments', 'review_history', 'time'):
        wf.variables.addVariable(v)

    wf.states.setInitialState('created')

    # Configure states
    sdef = wf.states['created']
    sdef.setProperties(title='Newly created', transitions=('submit', ))

    sdef = wf.states['submitted']
    sdef.setProperties(
        title='Submitted and pending review',
        transitions=(
            'apply',
            'reject',
        ),
        description=
        'Waiting on a reviewer to accept the patch and apply it to the correct content'
    )

    sdef = wf.states['applied']
    sdef.setProperties(
        title='Accepted by a reviwer',
        description=
        'The patch has been accepted and applied to a working copy of the content item.  The changes will not be public, however, until the item is published'
    )

    sdef = wf.states['rejected']
    sdef.setProperties(
        title='Rejected by a reviwer',
        description='The changes have been rejected by a reviewer.')

    # Configure transitions
    tdef = wf.transitions['apply']
    tdef.setProperties(title='Reviewer applies changes',
                       new_state_id='applied')

    tdef = wf.transitions['reject']
    tdef.setProperties(title='Reviewer rejects changes',
                       new_state_id='rejected')

    tdef = wf.transitions['submit']
    tdef.setProperties(title='Submit for review', new_state_id='submitted')

    # Configure variables
    wf.variables.setStateVar('review_state')

    vdef = wf.variables['action']
    vdef.setProperties(description='The last transition',
                       default_expr='transition/getId|nothing',
                       for_status=1,
                       update_always=1)

    vdef = wf.variables['actor']
    vdef.setProperties(description='The ID of the user who performed '
                       'the last transition',
                       default_expr='user/getId',
                       for_status=1,
                       update_always=1)

    vdef = wf.variables['comments']
    vdef.setProperties(
        description='Comments about the last transition',
        default_expr="python:state_change.kwargs.get('comment', '')",
        for_status=1,
        update_always=1)

    vdef = wf.variables['review_history']
    vdef.setProperties(description='Provides access to workflow history',
                       default_expr="state_change/getHistory",
                       props={'guard_permissions': View})

    vdef = wf.variables['time']
    vdef.setProperties(description='Time of the last transition',
                       default_expr="state_change/getDateTime",
                       for_status=1,
                       update_always=1)

    configureEventPermissions(wf)
    return wf
Ejemplo n.º 4
0
def createPloneboardWorkflow(id):
    ob=DCWorkflowDefinition(id)
    setupPloneboardWorkflow(ob)
    ob.setProperties(title='Ploneboard Workflow [Ploneboard]')
    return ob