Commit 4a204b8e authored by Arnaud Fontaine's avatar Arnaud Fontaine

erp5_core: Allow to jump from a Property Sheet to the Portal Types where it's being used.

parent 1db1c8e3
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ActionInformation" module="Products.CMFCore.ActionInformation"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/object_jump</string>
</tuple>
</value>
</item>
<item>
<key> <string>category</string> </key>
<value> <string>object_jump</string> </value>
</item>
<item>
<key> <string>condition</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>jump_portal_types</string> </value>
</item>
<item>
<key> <string>permissions</string> </key>
<value>
<tuple>
<string>View</string>
</tuple>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Action Information</string> </value>
</item>
<item>
<key> <string>priority</string> </key>
<value> <float>1.0</float> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Portal Types</string> </value>
</item>
<item>
<key> <string>visible</string> </key>
<value> <int>1</int> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Expression" module="Products.CMFCore.Expression"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/PropertySheet_jumpToPortalTypeList</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="Expression" module="Products.CMFCore.Expression"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>python:portal.Base_checkPermission(\'portal_types\', \'View\')</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
portal = context.getPortalObject()
translateString = portal.Base_translateString
# XXX: Merge with BaseType_jumpToPropertySheetList
value_list = context.getRecursivePortalTypeValueList()
if not len(value_list):
return context.Base_redirect(
'view',
keep_items={'portal_status_message':
translateString('No ${portal_type} related.',
mapping={'portal_type': 'Portal Type'})})
elif len(value_list) == 1:
value = value_list[0]
return value.Base_redirect(
'view',
keep_items={'portal_status_message':
translateString('${this_portal_type} related to ${that_portal_type}: ${that_title}.',
mapping={'this_portal_type': 'Portal Type',
'that_portal_type': context.getPortalType(),
'that_title': context.getTitleOrId()})})
return portal.portal_types.Base_redirect(
'view',
keep_items={'reset': 1,
'ignore_hide_rows': 1,
'uid': [value.getUid() for value in value_list]})
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>PropertySheet_jumpToPortalTypeList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -98,6 +98,7 @@ Property Existence Constraint | predicate
Property Existence Constraint | view
Property Sheet Tool | migrate_ps_from_fs
Property Sheet Tool | view
Property Sheet | jump_portal_types
Property Sheet | view
Property Type Validity Constraint | predicate
Property Type Validity Constraint | view
......
......@@ -196,3 +196,24 @@ class PropertySheet(Folder):
LOG("ERP5Type.Core.PropertySheet", INFO,
"Invalid property '%s' for Property Sheet '%s': %s" % \
(property_definition.getId(), self.getId(), str(e)))
security.declareProtected(Permissions.AccessContentsInformation,
'getRecursivePortalTypeValueList')
def getRecursivePortalTypeValueList(self):
"""
Get all the Portal Types where this Property Sheet is used
"""
portal = self.getPortalObject()
property_sheet_id = self.getId()
import erp5.portal_type
portal_type_value_list = []
for portal_type in portal.portal_types.contentValues():
portal_type_class = getattr(erp5.portal_type, portal_type.getId())
portal_type_class.loadClass()
for klass in portal_type_class.mro():
if (klass.__module__ == 'erp5.accessor_holder.property_sheet' and
klass.__name__ == property_sheet_id):
portal_type_value_list.append(portal_type)
return portal_type_value_list
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