From b4de995a8f94885aade961926c36bef8829c77ee Mon Sep 17 00:00:00 2001 From: Romain Courteaud <romain@nexedi.com> Date: Thu, 13 Mar 2008 10:45:56 +0000 Subject: [PATCH] Add a batch_mode parameter to Base_createCloneDocument to prevent redirection (if called from another python script for example) git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@19838 20353a03-c40f-0410-a6d1-a30d3c3de9de --- .../Base_createCloneDocument.xml | 34 ++++++++++++------- .../bootstrap/erp5_xhtml_style/bt/revision | 2 +- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/product/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/Base_createCloneDocument.xml b/product/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/Base_createCloneDocument.xml index e740101fbb..6aa8782020 100644 --- a/product/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/Base_createCloneDocument.xml +++ b/product/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/Base_createCloneDocument.xml @@ -85,10 +85,13 @@ else:\n parent = context.getParentValue()\n allowed_type_list = parent.getVisibleAllowedContentTypeList()\n if portal_type not in allowed_type_list:\n - return context.ERP5Site_redirect(\'%s/%s/view\' % (\n - parent.getUrl(), context.getId()),\n - keep_items={\'portal_status_message\':\n - translateString("You are not allowed to clone this object.")})\n + if batch_mode:\n + return None\n + else:\n + return context.ERP5Site_redirect(\'%s/%s/view\' % (\n + parent.getUrl(), context.getId()),\n + keep_items={\'portal_status_message\':\n + translateString("You are not allowed to clone this object.")})\n \n # prepare query params\n kw = {\'portal_type\' : translateString(portal_type)}\n @@ -105,12 +108,15 @@ if clone:\n new_object = directory[paste_result[0][\'new_id\']]\n message_kind = \'Clone\'\n \n -if not editable_mode: \n - form_id = \'view\'\n -msg = translateString("Created %s ${portal_type}." % message_kind, mapping = kw)\n -return new_object.Base_redirect(form_id, \n - editable_mode=1,\n - keep_items={\'portal_status_message\': msg})\n +if batch_mode:\n + return new_object\n +else:\n + if not editable_mode: \n + form_id = \'view\'\n + msg = translateString("Created %s ${portal_type}." % message_kind, mapping = kw)\n + return new_object.Base_redirect(form_id, \n + editable_mode=1,\n + keep_items={\'portal_status_message\': msg})\n </string> </value> </item> <item> @@ -127,7 +133,7 @@ return new_object.Base_redirect(form_id, \n </item> <item> <key> <string>_params</string> </key> - <value> <string>clone=1, form_id, editable_mode=0</string> </value> + <value> <string>clone=1, form_id, editable_mode=0, batch_mode=0</string> </value> </item> <item> <key> <string>_proxy_roles</string> </key> @@ -153,7 +159,7 @@ return new_object.Base_redirect(form_id, \n <dictionary> <item> <key> <string>co_argcount</string> </key> - <value> <int>3</int> </value> + <value> <int>4</int> </value> </item> <item> <key> <string>co_varnames</string> </key> @@ -162,6 +168,7 @@ return new_object.Base_redirect(form_id, \n <string>clone</string> <string>form_id</string> <string>editable_mode</string> + <string>batch_mode</string> <string>_getattr_</string> <string>context</string> <string>translateString</string> @@ -170,9 +177,9 @@ return new_object.Base_redirect(form_id, \n <string>_getitem_</string> <string>parent</string> <string>allowed_type_list</string> + <string>None</string> <string>kw</string> <string>getattr</string> - <string>None</string> <string>directory</string> <string>original_id</string> <string>clipboard</string> @@ -195,6 +202,7 @@ return new_object.Base_redirect(form_id, \n <int>1</int> <none/> <int>0</int> + <int>0</int> </tuple> </value> </item> diff --git a/product/ERP5/bootstrap/erp5_xhtml_style/bt/revision b/product/ERP5/bootstrap/erp5_xhtml_style/bt/revision index 99f9f071dc..03164581e1 100644 --- a/product/ERP5/bootstrap/erp5_xhtml_style/bt/revision +++ b/product/ERP5/bootstrap/erp5_xhtml_style/bt/revision @@ -1 +1 @@ -502 \ No newline at end of file +503 \ No newline at end of file -- 2.30.9