Commit ac25989c authored by Jens Vagelpohl's avatar Jens Vagelpohl

- Worklists and Transitions: Add icon expression properties to worklist

  and transition actions and their GenericSetup profiles.
parent 350bae91
......@@ -4,6 +4,9 @@ Products.DCWorkflow Changelog
2.2.0 (unreleased)
------------------
- Worklists and Transitions: Add icon expression properties to worklist
and transition actions and their GenericSetup profiles.
- Fixed an import error (Products.PageTemplates.TALES is gone on
Zope trunk). Because we require Zope >= 2.10, we don't need a
BBB conditional import.
......
......@@ -200,6 +200,7 @@ class DCWorkflowDefinition(WorkflowUIMixin, Folder):
'id': tid,
'name': tdef.actbox_name % info,
'url': tdef.actbox_url % info,
'icon': tdef.actbox_icon % info,
'permissions': (), # Predetermined.
'category': tdef.actbox_category,
'transition': tdef}))
......@@ -243,6 +244,7 @@ class DCWorkflowDefinition(WorkflowUIMixin, Folder):
res.append((id, {'id': id,
'name': qdef.actbox_name % fmt_data,
'url': qdef.actbox_url % fmt_data,
'icon': qdef.actbox_icon % fmt_data,
'permissions': (), # Predetermined.
'category': qdef.actbox_category}))
fmt_data._pop()
......
......@@ -48,6 +48,7 @@ class TransitionDefinition (SimpleItem):
guard = None
actbox_name = ''
actbox_url = ''
actbox_icon = ''
actbox_category = 'workflow'
var_exprs = None # A mapping.
script_name = None # Executed before transition
......@@ -112,7 +113,7 @@ class TransitionDefinition (SimpleItem):
trigger_type=TRIGGER_USER_ACTION, script_name='',
after_script_name='',
actbox_name='', actbox_url='',
actbox_category='workflow',
actbox_category='workflow', actbox_icon='',
props=None, REQUEST=None, description=''):
'''
'''
......@@ -129,6 +130,7 @@ class TransitionDefinition (SimpleItem):
self.guard = None
self.actbox_name = str(actbox_name)
self.actbox_url = str(actbox_url)
self.actbox_icon = str(actbox_icon)
self.actbox_category = str(actbox_category)
if REQUEST is not None:
return self.manage_properties(REQUEST, 'Properties changed.')
......
......@@ -41,6 +41,7 @@ class WorklistDefinition(SimpleItem):
var_matches = None # Compared with catalog when set.
actbox_name = ''
actbox_url = ''
actbox_icon = ''
actbox_category = 'global'
guard = None
......@@ -108,7 +109,7 @@ class WorklistDefinition(SimpleItem):
def setProperties(self, description,
actbox_name='', actbox_url='', actbox_category='global',
props=None, REQUEST=None):
actbox_icon='', props=None, REQUEST=None):
'''
'''
if props is None:
......@@ -129,6 +130,7 @@ class WorklistDefinition(SimpleItem):
self.actbox_name = str(actbox_name)
self.actbox_url = str(actbox_url)
self.actbox_category = str(actbox_category)
self.actbox_icon = str(actbox_icon)
g = Guard()
if g.changeFromProperties(props or REQUEST):
self.guard = g
......
......@@ -110,6 +110,13 @@ Initiated by user action
value="&dtml-actbox_url;" size="50" />
</td>
</tr>
<tr>
<th align="left">Icon URL (formatted)</th>
<td>
<input type="text" name="actbox_icon"
value="&dtml-actbox_icon;" size="50" />
</td>
</tr>
<tr>
<th align="left">Category</th>
<td>
......
......@@ -57,6 +57,13 @@
value="&dtml-actbox_url;" size="50" />
</td>
</tr>
<tr>
<th align="left">Icon URL (formatted)</th>
<td>
<input type="text" name="actbox_icon"
value="&dtml-actbox_icon;" size="50" />
</td>
</tr>
<tr>
<th align="left">Category</th>
<td>
......
......@@ -437,6 +437,9 @@ class WorkflowDefinitionConfigurator( Implicit ):
'actbox_url' -- the URL of the action by which the user
triggers the transition
'actbox_icon' -- the icon URL for the action by which the user
triggers the transition
'actbox_category' -- the category of the action by which the user
triggers the transition
......@@ -475,6 +478,7 @@ class WorkflowDefinitionConfigurator( Implicit ):
, 'after_script_name' : v.after_script_name
, 'actbox_name' : v.actbox_name
, 'actbox_url' : v.actbox_url
, 'actbox_icon' : v.actbox_icon
, 'actbox_category' : v.actbox_category
, 'variables' : v_info
, 'guard_permissions' : guard.permissions
......@@ -509,6 +513,9 @@ class WorkflowDefinitionConfigurator( Implicit ):
'actbox_url' -- the URL of the "action" corresponding to the
worklist
'actbox_icon' -- the icon URL of the "action" corresponding to
the worklist
'actbox_category' -- the category of the "action" corresponding
to the worklist
......@@ -539,6 +546,7 @@ class WorkflowDefinitionConfigurator( Implicit ):
, 'var_match' : var_match
, 'actbox_name' : v.actbox_name
, 'actbox_url' : v.actbox_url
, 'actbox_icon' : v.actbox_icon
, 'actbox_category' : v.actbox_category
, 'guard_permissions' : guard.permissions
, 'guard_roles' : guard.roles
......@@ -800,13 +808,14 @@ def _extractActionNode( parent, encoding=None ):
assert len( nodes ) <= 1, nodes
if len( nodes ) < 1:
return { 'name' : '', 'url' : '', 'category' : '' }
return { 'name' : '', 'url' : '', 'category' : '', 'icon': ''}
node = nodes[ 0 ]
return { 'name' : _coalesceTextNodeChildren( node, encoding )
, 'url' : _getNodeAttribute( node, 'url', encoding )
, 'category' : _getNodeAttribute( node, 'category', encoding )
, 'icon' : _queryNodeAttribute( node, 'icon', '', encoding )
}
def _extractGuardNode( parent, encoding=None ):
......@@ -1087,6 +1096,7 @@ def _initDCWorkflowTransitions( workflow, transitions ):
, actbox_name = action[ 'name' ]
, actbox_url = action[ 'url' ]
, actbox_category = action[ 'category' ]
, actbox_icon = action.get('icon', '')
, props = props
)
var_mapping = [(name, Expression(text)) for name, text in
......@@ -1121,6 +1131,7 @@ def _initDCWorkflowWorklists( workflow, worklists ):
, actbox_name = action[ 'name' ]
, actbox_url = action[ 'url' ]
, actbox_category = action[ 'category' ]
, actbox_icon = action.get('icon', '')
, props = props
)
......
......@@ -97,6 +97,7 @@
new_state="private" trigger="USER"
before_script="" after_script="">
<action url="%(content_url)s/content_hide_form"
icon="%(portal_url)s/retract_icon.png"
category="workflow">Make private</action>
<guard>
<guard-role>Owner</guard-role>
......@@ -108,6 +109,7 @@
new_state="published" trigger="USER"
before_script="" after_script="">
<action url="%(object_url)s/content_publish_form"
icon="%(portal_url)s/approve_icon.png"
category="workflow">Publish</action>
<guard>
<guard-permission>Review portal content</guard-permission>
......@@ -119,6 +121,7 @@
new_state="visible" trigger="USER"
before_script="" after_script="">
<action url="%(object_url)s/content_reject_form"
icon="%(portal_url)s/reject_icon.png"
category="workflow">Reject</action>
<guard>
<guard-permission>Review portal content</guard-permission>
......@@ -130,6 +133,7 @@
new_state="visible" trigger="USER"
before_script="" after_script="">
<action url="%(object_url)s/content_retract_form"
icon="%(portal_url)s/retract_icon.png"
category="workflow">Retract</action>
<guard>
<guard-permission>Request review</guard-permission>
......@@ -141,6 +145,7 @@
new_state="visible" trigger="USER"
before_script="" after_script="">
<action url="%(content_url)s/content_show_form"
icon="%(portal_url)s/approve_icon.png"
category="workflow">Make visible</action>
<guard>
<guard-role>Owner</guard-role>
......@@ -152,6 +157,7 @@
new_state="pending" trigger="USER"
before_script="" after_script="">
<action url="%(object_url)s/content_submit_form"
icon="%(portal_url)s/submit_icon.png"
category="workflow">Submit</action>
<guard>
<guard-permission>Request review</guard-permission>
......@@ -161,6 +167,7 @@
<worklist worklist_id="reviewer_queue" title="">
<description>Reviewer tasks</description>
<action url="%(portal_url)s/search?review_state=pending"
icon="%(portal_url)s/worklist_icon.png"
category="global">Pending (%(count)d)</action>
<guard>
<guard-permission>Review portal content</guard-permission>
......
......@@ -144,11 +144,12 @@ class _WorkflowSetup(WorkflowSetupBase):
, after_script_name=v[ 5 ]
, actbox_name=v[ 6 ]
, actbox_url=v[ 7 ]
, actbox_category=v[ 8 ]
, actbox_icon=v[ 8 ]
, actbox_category=v[ 9 ]
, props=self._genGuardProps( *v[ -4: ] )
)
for k, v in v[ 9 ].items():
for k, v in v[ 10 ].items():
transition.addVariable( k, v )
def _initWorklists( self, dcworkflow ):
......@@ -168,7 +169,8 @@ class _WorkflowSetup(WorkflowSetupBase):
worklist.setProperties( description=v[ 1 ]
, actbox_name=v[ 3 ]
, actbox_url=v[ 4 ]
, actbox_category=v[ 5 ]
, actbox_icon=v[ 5 ]
, actbox_category=v[ 6 ]
, props=props
)
......@@ -377,14 +379,15 @@ class WorkflowDefinitionConfiguratorTests( _WorkflowSetup, _GuardChecker ):
self.assertEqual( info[ 'after_script_name' ], expected[ 5 ] )
self.assertEqual( info[ 'actbox_name' ], expected[ 6 ] )
self.assertEqual( info[ 'actbox_url' ], expected[ 7 ] )
self.assertEqual( info[ 'actbox_category' ], expected[ 8 ] )
self.assertEqual( info[ 'actbox_icon' ], expected[ 8 ] )
self.assertEqual( info[ 'actbox_category' ], expected[ 9 ] )
variables = info[ 'variables' ]
self.assertEqual( len( variables ), len( expected[ 9 ] ) )
self.assertEqual( len( variables ), len( expected[ 10 ] ) )
for v_info in variables:
self.assertEqual( v_info[ 'expr' ]
, expected[ 9 ][ v_info[ 'name' ] ] )
, expected[ 10 ][ v_info[ 'name' ] ] )
self._assertGuard( info, *expected[ -4: ] )
......@@ -415,7 +418,8 @@ class WorkflowDefinitionConfiguratorTests( _WorkflowSetup, _GuardChecker ):
self.assertEqual( info[ 'description' ], expected[ 1 ] )
self.assertEqual( info[ 'actbox_name' ], expected[ 3 ] )
self.assertEqual( info[ 'actbox_url' ], expected[ 4 ] )
self.assertEqual( info[ 'actbox_category' ], expected[ 5 ] )
self.assertEqual( info[ 'actbox_icon' ], expected[ 5 ] )
self.assertEqual( info[ 'actbox_category' ], expected[ 6 ] )
var_match = info[ 'var_match' ]
self.assertEqual( len( var_match ), len( expected[ 2 ] ) )
......@@ -765,18 +769,19 @@ class WorkflowDefinitionConfiguratorTests( _WorkflowSetup, _GuardChecker ):
action = transition[ 'action' ]
self.assertEqual( action.get( 'name', '' ), expected[ 6 ] )
self.assertEqual( action.get( 'url', '' ), expected[ 7 ] )
self.assertEqual( action.get( 'category', '' ), expected[ 8 ] )
self.assertEqual( action.get( 'icon', '' ), expected[ 8 ] )
self.assertEqual( action.get( 'category', '' ), expected[ 9 ] )
self.assertEqual( transition[ 'variables' ], expected[ 9 ] )
self.assertEqual( transition[ 'variables' ], expected[ 10 ] )
guard = transition[ 'guard' ]
self.assertEqual( tuple( guard.get( 'permissions', () ) )
, expected[ 10 ] )
self.assertEqual( tuple( guard.get( 'roles', () ) )
, expected[ 11 ] )
self.assertEqual( tuple( guard.get( 'groups', () ) )
self.assertEqual( tuple( guard.get( 'roles', () ) )
, expected[ 12 ] )
self.assertEqual( guard.get( 'expression', '' ), expected[ 13 ] )
self.assertEqual( tuple( guard.get( 'groups', () ) )
, expected[ 13 ] )
self.assertEqual( guard.get( 'expression', '' ), expected[ 14 ] )
def test_parseWorkflowXML_normal_variables( self ):
......@@ -907,16 +912,17 @@ class WorkflowDefinitionConfiguratorTests( _WorkflowSetup, _GuardChecker ):
action = worklist[ 'action' ]
self.assertEqual( action.get( 'name', '' ), expected[ 3 ] )
self.assertEqual( action.get( 'url', '' ), expected[ 4 ] )
self.assertEqual( action.get( 'category', '' ), expected[ 5 ] )
self.assertEqual( action.get( 'icon', '' ), expected[ 5 ] )
self.assertEqual( action.get( 'category', '' ), expected[ 6 ] )
guard = worklist[ 'guard' ]
self.assertEqual( tuple( guard.get( 'permissions', () ) )
, expected[ 6 ] )
self.assertEqual( tuple( guard.get( 'roles', () ) )
, expected[ 7 ] )
self.assertEqual( tuple( guard.get( 'groups', () ) )
self.assertEqual( tuple( guard.get( 'roles', () ) )
, expected[ 8 ] )
self.assertEqual( guard.get( 'expression', '' ), expected[ 9 ] )
self.assertEqual( tuple( guard.get( 'groups', () ) )
, expected[ 9 ] )
self.assertEqual( guard.get( 'expression', '' ), expected[ 10 ] )
def test_parseWorkflowXML_normal_permissions( self ):
......@@ -1094,6 +1100,7 @@ _WF_TRANSITIONS = \
, ''
, 'Open'
, 'string:${object_url}/open_for_modifications'
, 'string:${portal_url}/open.png'
, 'workflow'
, { 'when_opened' : 'object/ZopeTime' }
, ( 'Open content for modifications', )
......@@ -1109,6 +1116,7 @@ _WF_TRANSITIONS = \
, 'after_close'
, 'Close'
, 'string:${object_url}/close_for_modifications'
, 'string:${portal_url}/close.png'
, 'workflow'
, {}
, ()
......@@ -1124,6 +1132,7 @@ _WF_TRANSITIONS = \
, 'after_kill'
, 'Kill'
, 'string:${object_url}/kill_object'
, 'string:${portal_url}/kill.png'
, 'workflow'
, { 'killed_by' : 'string:${user/getId}' }
, ()
......@@ -1140,6 +1149,7 @@ _WF_TRANSITIONS = \
, ''
, ''
, ''
, ''
, { 'when_expired' : 'object/ZopeTime' }
, ()
, ()
......@@ -1154,6 +1164,7 @@ _WF_WORKLISTS = \
, { 'state' : ( 'expired', ) }
, 'Expired items'
, 'string:${portal_url}/expired_items'
, 'string:${portal_url}/expired.png'
, 'workflow'
, ( 'Restore expired content', )
, ()
......@@ -1165,6 +1176,7 @@ _WF_WORKLISTS = \
, { 'state' : ( 'open', 'closed' ) }
, 'Expired items'
, 'string:${portal_url}/expired_items'
, 'string:${portal_url}/alive.png'
, 'workflow'
, ( 'Restore expired content', )
, ()
......@@ -1623,7 +1635,8 @@ _NORMAL_WORKFLOW_EXPORT = """\
<description>Close the object for modifications</description>
<action
category="workflow"
url="string:${object_url}/close_for_modifications">Close</action>
url="string:${object_url}/close_for_modifications"
icon="string:${portal_url}/close.png">Close</action>
<guard>
<guard-role>Owner</guard-role>
<guard-role>Manager</guard-role>
......@@ -1653,7 +1666,8 @@ _NORMAL_WORKFLOW_EXPORT = """\
<description>Make the object permanently unavailable.</description>
<action
category="workflow"
url="string:${object_url}/kill_object">Kill</action>
url="string:${object_url}/kill_object"
icon="string:${portal_url}/kill.png">Kill</action>
<guard>
<guard-group>Content_assassins</guard-group>
</guard>
......@@ -1670,7 +1684,8 @@ _NORMAL_WORKFLOW_EXPORT = """\
<description>Open the object for modifications</description>
<action
category="workflow"
url="string:${object_url}/open_for_modifications">Open</action>
url="string:${object_url}/open_for_modifications"
icon="string:${portal_url}/open.png">Open</action>
<guard>
<guard-permission>Open content for modifications</guard-permission>
</guard>
......@@ -1683,7 +1698,8 @@ _NORMAL_WORKFLOW_EXPORT = """\
<description>Worklist for content not yet expired / killed</description>
<action
category="workflow"
url="string:${portal_url}/expired_items">Expired items</action>
url="string:${portal_url}/expired_items"
icon="string:${portal_url}/alive.png">Expired items</action>
<guard>
<guard-permission>Restore expired content</guard-permission>
</guard>
......@@ -1695,7 +1711,8 @@ _NORMAL_WORKFLOW_EXPORT = """\
<description>Worklist for expired content</description>
<action
category="workflow"
url="string:${portal_url}/expired_items">Expired items</action>
url="string:${portal_url}/expired_items"
icon="string:${portal_url}/expired.png">Expired items</action>
<guard>
<guard-permission>Restore expired content</guard-permission>
</guard>
......@@ -2313,21 +2330,22 @@ class Test_importWorkflow(_WorkflowSetup, _GuardChecker):
self.assertEqual( transition.after_script_name, expected[ 5 ] )
self.assertEqual( transition.actbox_name, expected[ 6 ] )
self.assertEqual( transition.actbox_url, expected[ 7 ] )
self.assertEqual( transition.actbox_category, expected[ 8 ] )
self.assertEqual( transition.actbox_icon, expected[ 8 ] )
self.assertEqual( transition.actbox_category, expected[ 9 ] )
var_exprs = transition.var_exprs
self.assertEqual( len( var_exprs ), len( expected[ 9 ] ) )
self.assertEqual( len( var_exprs ), len( expected[ 10 ] ) )
for var_id, expr in var_exprs.items():
self.assertEqual( expr.text, expected[ 9 ][ var_id ] )
self.assertEqual( expr.text, expected[ 10 ][ var_id ] )
guard = transition.getGuard()
self.assertEqual( guard.permissions, expected[ 10 ] )
self.assertEqual( guard.roles, expected[ 11 ] )
self.assertEqual( guard.groups, expected[ 12 ] )
self.assertEqual( guard.getExprText(), expected[ 13 ] )
self.assertEqual( guard.permissions, expected[ 11 ] )
self.assertEqual( guard.roles, expected[ 12 ] )
self.assertEqual( guard.groups, expected[ 13 ] )
self.assertEqual( guard.getExprText(), expected[ 14 ] )
def test_from_empty_dcworkflow_workflow_worklists( self ):
......@@ -2364,14 +2382,15 @@ class Test_importWorkflow(_WorkflowSetup, _GuardChecker):
self.assertEqual( worklist.actbox_name, expected[ 3 ] )
self.assertEqual( worklist.actbox_url, expected[ 4 ] )
self.assertEqual( worklist.actbox_category, expected[ 5 ] )
self.assertEqual( worklist.actbox_icon, expected[ 5 ] )
self.assertEqual( worklist.actbox_category, expected[ 6 ] )
guard = worklist.getGuard()
self.assertEqual( guard.permissions, expected[ 6 ] )
self.assertEqual( guard.roles, expected[ 7 ] )
self.assertEqual( guard.groups, expected[ 8 ] )
self.assertEqual( guard.getExprText(), expected[ 9 ] )
self.assertEqual( guard.permissions, expected[ 7 ] )
self.assertEqual( guard.roles, expected[ 8 ] )
self.assertEqual( guard.groups, expected[ 9 ] )
self.assertEqual( guard.getExprText(), expected[ 10 ] )
def test_from_old_dcworkflow_workflow_scripts( self ):
......
......@@ -83,6 +83,7 @@
category="CATEGORY"
tal:condition="transition/actbox_name"
tal:attributes="url transition/actbox_url;
icon transition/actbox_icon;
category transition/actbox_category;
"
tal:content="transition/actbox_name">ACTION NAME</action>
......@@ -126,6 +127,7 @@
tal:condition="worklist/actbox_name"
tal:attributes="url worklist/actbox_url;
category worklist/actbox_category;
icon worklist/actbox_icon;
"
tal:content="worklist/actbox_name">ACTION NAME</action>
<guard
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment