Commit b4de995a authored by Romain Courteaud's avatar Romain Courteaud

Add a batch_mode parameter to Base_createCloneDocument to prevent redirection...

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
parent d4c709cd
...@@ -85,6 +85,9 @@ else:\n ...@@ -85,6 +85,9 @@ else:\n
parent = context.getParentValue()\n parent = context.getParentValue()\n
allowed_type_list = parent.getVisibleAllowedContentTypeList()\n allowed_type_list = parent.getVisibleAllowedContentTypeList()\n
if portal_type not in allowed_type_list:\n if portal_type not in allowed_type_list:\n
if batch_mode:\n
return None\n
else:\n
return context.ERP5Site_redirect(\'%s/%s/view\' % (\n return context.ERP5Site_redirect(\'%s/%s/view\' % (\n
parent.getUrl(), context.getId()),\n parent.getUrl(), context.getId()),\n
keep_items={\'portal_status_message\':\n keep_items={\'portal_status_message\':\n
...@@ -105,10 +108,13 @@ if clone:\n ...@@ -105,10 +108,13 @@ if clone:\n
new_object = directory[paste_result[0][\'new_id\']]\n new_object = directory[paste_result[0][\'new_id\']]\n
message_kind = \'Clone\'\n message_kind = \'Clone\'\n
\n \n
if not editable_mode: \n if batch_mode:\n
return new_object\n
else:\n
if not editable_mode: \n
form_id = \'view\'\n form_id = \'view\'\n
msg = translateString("Created %s ${portal_type}." % message_kind, mapping = kw)\n msg = translateString("Created %s ${portal_type}." % message_kind, mapping = kw)\n
return new_object.Base_redirect(form_id, \n return new_object.Base_redirect(form_id, \n
editable_mode=1,\n editable_mode=1,\n
keep_items={\'portal_status_message\': msg})\n keep_items={\'portal_status_message\': msg})\n
</string> </value> </string> </value>
...@@ -127,7 +133,7 @@ return new_object.Base_redirect(form_id, \n ...@@ -127,7 +133,7 @@ return new_object.Base_redirect(form_id, \n
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <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>
<item> <item>
<key> <string>_proxy_roles</string> </key> <key> <string>_proxy_roles</string> </key>
...@@ -153,7 +159,7 @@ return new_object.Base_redirect(form_id, \n ...@@ -153,7 +159,7 @@ return new_object.Base_redirect(form_id, \n
<dictionary> <dictionary>
<item> <item>
<key> <string>co_argcount</string> </key> <key> <string>co_argcount</string> </key>
<value> <int>3</int> </value> <value> <int>4</int> </value>
</item> </item>
<item> <item>
<key> <string>co_varnames</string> </key> <key> <string>co_varnames</string> </key>
...@@ -162,6 +168,7 @@ return new_object.Base_redirect(form_id, \n ...@@ -162,6 +168,7 @@ return new_object.Base_redirect(form_id, \n
<string>clone</string> <string>clone</string>
<string>form_id</string> <string>form_id</string>
<string>editable_mode</string> <string>editable_mode</string>
<string>batch_mode</string>
<string>_getattr_</string> <string>_getattr_</string>
<string>context</string> <string>context</string>
<string>translateString</string> <string>translateString</string>
...@@ -170,9 +177,9 @@ return new_object.Base_redirect(form_id, \n ...@@ -170,9 +177,9 @@ return new_object.Base_redirect(form_id, \n
<string>_getitem_</string> <string>_getitem_</string>
<string>parent</string> <string>parent</string>
<string>allowed_type_list</string> <string>allowed_type_list</string>
<string>None</string>
<string>kw</string> <string>kw</string>
<string>getattr</string> <string>getattr</string>
<string>None</string>
<string>directory</string> <string>directory</string>
<string>original_id</string> <string>original_id</string>
<string>clipboard</string> <string>clipboard</string>
...@@ -195,6 +202,7 @@ return new_object.Base_redirect(form_id, \n ...@@ -195,6 +202,7 @@ return new_object.Base_redirect(form_id, \n
<int>1</int> <int>1</int>
<none/> <none/>
<int>0</int> <int>0</int>
<int>0</int>
</tuple> </tuple>
</value> </value>
</item> </item>
......
502 503
\ 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