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

Fix Base_createCloneDocument for categories + optimizations

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