Commit 547fdec0 authored by Julien Muchembled's avatar Julien Muchembled

'action_expression' -> 'action'

git-svn-id: https://svn.erp5.org/repos/public/erp5/sandbox/portal_types@29257 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 98c0980b
...@@ -79,7 +79,7 @@ module_list_form_id = (\'%s_view%sList\' % (module_portal_type,\n ...@@ -79,7 +79,7 @@ module_list_form_id = (\'%s_view%sList\' % (module_portal_type,\n
module_portal_type_value.newContent(portal_type=\'Action Information\',\n module_portal_type_value.newContent(portal_type=\'Action Information\',\n
reference="view",\n reference="view",\n
title="View",\n title="View",\n
action_expression="string:${object_url}/%s" % module_list_form_id,\n action="string:${object_url}/%s" % module_list_form_id,\n
action_type="object_list")\n action_type="object_list")\n
\n \n
# Create the skin folder if does not exist yet\n # Create the skin folder if does not exist yet\n
...@@ -186,7 +186,7 @@ portal.portal_workflow.setChainForPortalTypes([object_portal_type_id],\n ...@@ -186,7 +186,7 @@ portal.portal_workflow.setChainForPortalTypes([object_portal_type_id],\n
object_portal_type_value.newContent(portal_type=\'Action Information\',\n object_portal_type_value.newContent(portal_type=\'Action Information\',\n
reference="view",\n reference="view",\n
title="View",\n title="View",\n
action_expression="string:${object_url}/%s" % form_view_id,\n action="string:${object_url}/%s" % form_view_id,\n
action_type="object_view")\n action_type="object_view")\n
\n \n
# Finally add the module to the site\n # Finally add the module to the site\n
......
...@@ -84,17 +84,17 @@ class ActionInformation(XMLObject): ...@@ -84,17 +84,17 @@ class ActionInformation(XMLObject):
return condition is None or condition(ec) return condition is None or condition(ec)
return False return False
security.declarePublic('getVisibility') security.declarePrivate('getActionUrl')
def getVisibility(self): def getActionUrl(self, ec):
"""Return whether the action should be visible in the CMF UI""" action = self.getAction()
return self.isVisible() return action is not None and action(ec) or ''
def _setActionExpression(self, value): def _setAction(self, value):
"""Overridden setter for 'action' to accept strings and clean null values """Overridden setter for 'action' to accept strings and clean null values
""" """
if isinstance(value, basestring): if isinstance(value, basestring):
value = value and Expression(value) or None value = value and Expression(value) or None
self._baseSetActionExpression(value) self._baseSetAction(value)
def _setCondition(self, value): def _setCondition(self, value):
"""Overridden setter for 'condition' to accept string and clean null values """Overridden setter for 'condition' to accept string and clean null values
""" """
...@@ -108,6 +108,11 @@ class ActionInformation(XMLObject): ...@@ -108,6 +108,11 @@ class ActionInformation(XMLObject):
value = value and Expression(value) or None value = value and Expression(value) or None
self._baseSetIcon(value) self._baseSetIcon(value)
def getAction(self):
"""Overridden getter for 'action' to clean null values"""
if getattr(aq_base(self), 'action', None) == '':
del self.action
return self._baseGetAction()
def getCondition(self): def getCondition(self):
"""Overridden getter for 'condition' to clean null values""" """Overridden getter for 'condition' to clean null values"""
if getattr(aq_base(self), 'condition', None) == '': if getattr(aq_base(self), 'condition', None) == '':
...@@ -122,7 +127,7 @@ class ActionInformation(XMLObject): ...@@ -122,7 +127,7 @@ class ActionInformation(XMLObject):
security.declareProtected(AccessContentsInformation, 'getActionText') security.declareProtected(AccessContentsInformation, 'getActionText')
def getActionText(self): def getActionText(self):
"""Return the text of the action expression""" """Return the text of the action expression"""
return getattr(self.getActionExpression(), 'text', None) return getattr(self.getAction(), 'text', None)
security.declareProtected(AccessContentsInformation, 'getConditionText') security.declareProtected(AccessContentsInformation, 'getConditionText')
def getConditionText(self): def getConditionText(self):
"""Return the text of the condition expression""" """Return the text of the condition expression"""
...@@ -141,7 +146,3 @@ class ActionInformation(XMLObject): ...@@ -141,7 +146,3 @@ class ActionInformation(XMLObject):
self.getActionText(), self.getActionText(),
self.getConditionText()] self.getConditionText()]
return ' '.join(filter(None, search_source_list)) return ' '.join(filter(None, search_source_list))
security.declarePrivate('getActionUrl')
def getActionUrl(self, ec):
return self.getActionExpression()(ec)
...@@ -574,6 +574,7 @@ class ERP5TypeInformation(XMLObject, ...@@ -574,6 +574,7 @@ class ERP5TypeInformation(XMLObject,
v = v.__class__(v.text) v = v.__class__(v.text)
setattr(action, {'id': 'reference', setattr(action, {'id': 'reference',
'priority': 'float_index', 'priority': 'float_index',
'permissions': 'action_permission',
}.get(k, k), v) }.get(k, k), v)
action.uid = None action.uid = None
action = self[self._setObject(action.id, action, set_owner=0)] action = self[self._setObject(action.id, action, set_owner=0)]
...@@ -585,13 +586,12 @@ class ERP5TypeInformation(XMLObject, ...@@ -585,13 +586,12 @@ class ERP5TypeInformation(XMLObject,
from Products.CMFCore.ActionInformation import ActionInformation from Products.CMFCore.ActionInformation import ActionInformation
old_action = ActionInformation(action.reference, old_action = ActionInformation(action.reference,
category=action.getActionType(), category=action.getActionType(),
# We don't have the same default values for the following properties:
priority=action.getFloatIndex(), priority=action.getFloatIndex(),
permissions=tuple(action.getActionPermissionList())) permissions=tuple(action.getActionPermissionList()))
for k, v in action.__dict__.iteritems(): for k, v in action.__dict__.iteritems():
if k in ('action', 'condition', 'icon'): if k in ('action', 'condition', 'icon'):
v = v.__class__(v.text) v = v.__class__(v.text)
elif k in ('id', 'float_index', 'permissions', 'reference'): elif k in ('id', 'float_index', 'action_permission', 'reference'):
continue continue
setattr(old_action, k, v) setattr(old_action, k, v)
return old_action return old_action
......
...@@ -44,7 +44,6 @@ class ActionInformation: ...@@ -44,7 +44,6 @@ class ActionInformation:
'mode': 'w', 'mode': 'w',
}, },
{ 'id': 'action_permission', { 'id': 'action_permission',
'storage_id': 'permissions', # CMF Compatibility
'type': 'lines', 'type': 'lines',
'description': 'The permissions required to use the action', 'description': 'The permissions required to use the action',
'mode': 'w', 'mode': 'w',
...@@ -62,8 +61,7 @@ class ActionInformation: ...@@ -62,8 +61,7 @@ class ActionInformation:
'mode': 'w', 'mode': 'w',
'default': True, 'default': True,
}, },
{ 'id': 'action_expression', # CMF Compatibility { 'id': 'action',
'storage_id': 'action',
'type': 'object', 'type': 'object',
'description': 'TALES Expression to define the URL of the action', 'description': 'TALES Expression to define the URL of the action',
'mode': 'w', 'mode': 'w',
......
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