Commit 0ee3eaa0 authored by Julien Muchembled's avatar Julien Muchembled

Fix Base_createCloneDocument for categories + optimizations

parent 866c9cd8
...@@ -50,40 +50,29 @@ ...@@ -50,40 +50,29 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>REQUEST=context.REQUEST\n <value> <string>portal = context.getPortalObject()\n
error_message = \'\'\n
Base_translateString = context.Base_translateString\n
\n \n
if context.cb_dataValid:\n if context.cb_dataValid:\n
# We first look if the content of objects to paste is allowed\n
# inside this folder\n
object_list = context.cb_dataItems()\n object_list = context.cb_dataItems()\n
try:\n try:\n
portal_type_list = [x.getPortalType() for x in object_list]\n portal_type_set = set(x.getPortalType() for x in object_list)\n
except AttributeError:\n except AttributeError:\n
error_message = Base_translateString(\'Sorry, you can not paste these items here.\')\n error_message = \'Sorry, you can not paste these items here.\'\n
else:\n else:\n
allowed_type_list = [x for x in context.getVisibleAllowedContentTypeList()]\n if portal_type_set.issubset(context.getVisibleAllowedContentTypeList()):\n
for portal_type in portal_type_list:\n
if portal_type not in allowed_type_list:\n
error_message = Base_translateString(\'Sorry, you can not paste these items here.\')\n
\n
if context.cb_dataValid and error_message==\'\':\n
try:\n try:\n
new_item_list = context.manage_pasteObjects(REQUEST[\'__cp\'])\n new_item_list = context.manage_pasteObjects(portal.REQUEST[\'__cp\'])\n
except KeyError:\n except KeyError:\n
return context.Base_redirect(form_id,\n error_message = \'Nothing to paste.\'\n
keep_items=dict(portal_status_message=Base_translateString(\'Nothing to paste.\')))\n
else:\n else:\n
new_id_list = [i[\'new_id\'] for i in new_item_list]\n #new_id_list = [i[\'new_id\'] for i in new_item_list]\n
return context.Base_redirect(form_id,\n error_message = \'Items paste in progress.\'\n
keep_items=dict(portal_status_message=Base_translateString(\'Items paste in progress.\')))\n else:\n
\n error_message = \'Sorry, you can not paste these items here.\'\n
elif context.cb_dataValid and error_message != \'\':\n else:\n
return context.Base_redirect(form_id, keep_items=dict(portal_status_message=error_message))\n error_message = \'Copy or cut one or more items to paste first.\'\n
\n return context.Base_redirect(form_id, keep_items=dict(\n
error_message = Base_translateString(\'Copy or cut one or more items to paste first.\')\n portal_status_message=portal.Base_translateString(error_message)))\n
return context.Base_redirect(form_id, keep_items=dict(portal_status_message=error_message))\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
......
41093 41094
\ No newline at end of file \ No newline at end of file
...@@ -56,8 +56,9 @@ ...@@ -56,8 +56,9 @@
\n \n
Pretty messages are provided to the user.\n Pretty messages are provided to the user.\n
"""\n """\n
translateString = context.Base_translateString\n portal = context.getPortalObject()\n
form_data = context.REQUEST.form\n translateString = portal.Base_translateString\n
form_data = portal.REQUEST.form\n
\n \n
if clone:\n if clone:\n
portal_type = context.getPortalType()\n portal_type = context.getPortalType()\n
...@@ -65,10 +66,12 @@ else:\n ...@@ -65,10 +66,12 @@ else:\n
portal_type = form_data[\'clone_portal_type\']\n portal_type = form_data[\'clone_portal_type\']\n
\n \n
# We copy contents in place if possible\n # We copy contents in place if possible\n
directory = getattr(context, \'original_container\', None) or context.getParentValue()\n try:\n
allowed_type_list = directory.getVisibleAllowedContentTypeList()\n directory = context.aq_explicit.original_container\n
is_user_allowed_copy_or_move = context.Base_checkPermission(context.getRelativeUrl(), \'Copy or Move\')\n except AttributeError:\n
if portal_type not in allowed_type_list or not is_user_allowed_copy_or_move:\n directory = context.getParentValue()\n
if not (portal_type in directory.getVisibleAllowedContentTypeList() and\n
portal.portal_membership.checkPermission(\'Copy or Move\', context)):\n
if batch_mode:\n if batch_mode:\n
return None\n return None\n
else:\n else:\n
...@@ -90,7 +93,10 @@ if web_mode:\n ...@@ -90,7 +93,10 @@ if web_mode:\n
# Standard cloning method\n # Standard cloning method\n
if clone:\n if clone:\n
# Copy and paste the object\n # Copy and paste the object\n
original_id = getattr(context, \'original_id\', None) or context.getId()\n try:\n
original_id = context.aq_explicit.original_id\n
except AttributeError:\n
original_id = context.getId()\n
# This is required for objects acquired in Web Section\n # This is required for objects acquired in Web Section\n
clipboard = directory.manage_copyObjects(ids=[original_id])\n clipboard = directory.manage_copyObjects(ids=[original_id])\n
context.REQUEST.set(\'__cp\', clipboard) # CopySupport is using this to set\n context.REQUEST.set(\'__cp\', clipboard) # CopySupport is using this to set\n
......
1098 1099
\ No newline at end of file \ No newline at end of file
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