diff --git a/bt5/erp5_hal_json_style/ActionTemplateItem/portal_types/portal_actions/clone_document.xml b/bt5/erp5_hal_json_style/ActionTemplateItem/portal_types/portal_actions/clone_document.xml index fc22d569591e086e0599a22b0b5dcb2add8b13b4..58837922ab3d7c9271034d169efd3ca040fe5960 100644 --- a/bt5/erp5_hal_json_style/ActionTemplateItem/portal_types/portal_actions/clone_document.xml +++ b/bt5/erp5_hal_json_style/ActionTemplateItem/portal_types/portal_actions/clone_document.xml @@ -78,7 +78,7 @@ <dictionary> <item> <key> <string>text</string> </key> - <value> <string>python: (getattr(object, \'getParentValue\', None) is not None) and (object.getPortalType() not in portal.getPortalModuleTypeList()) and (portal.Base_checkPermission(object.getParentValue().getRelativeUrl(), \'Add portal content\')) and (object.getPortalType() in object.getParentValue().getVisibleAllowedContentTypeList())</string> </value> + <value> <string>python: object.Base_checkCloneDocumentPermission()</string> </value> </item> </dictionary> </pickle> diff --git a/bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/Base_checkCloneDocumentPermission.py b/bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/Base_checkCloneDocumentPermission.py new file mode 100644 index 0000000000000000000000000000000000000000..8d11b984ef83eed195e71c88f2d92ce7de6c4c39 --- /dev/null +++ b/bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/Base_checkCloneDocumentPermission.py @@ -0,0 +1,15 @@ +from zExceptions import Unauthorized +try: + portal = context.getPortalObject() + if getattr(context, 'getParentValue', None) is None: + return False + portal_type = context.getPortalType() + if portal_type in portal.getPortalModuleTypeList(): + return False + parent = context.getParentValue() + return ( + (portal.Base_checkPermission(parent.getRelativeUrl(), 'Add portal content')) and + (portal_type in parent.getVisibleAllowedContentTypeList()) + ) +except Unauthorized: + return False diff --git a/bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/Base_checkCloneDocumentPermission.xml b/bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/Base_checkCloneDocumentPermission.xml new file mode 100644 index 0000000000000000000000000000000000000000..b0eb2f30ae630f95e082f37655c2f3d3b77eaf77 --- /dev/null +++ b/bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/Base_checkCloneDocumentPermission.xml @@ -0,0 +1,62 @@ +<?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>Base_checkCloneDocumentPermission</string> </value> + </item> + </dictionary> + </pickle> + </record> +</ZopeData>