[Erp5-report] r22619 - /erp5/trunk/products/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateIte...

nobody at svn.erp5.org nobody at svn.erp5.org
Tue Jul 22 18:31:14 CEST 2008


Author: rafael
Date: Tue Jul 22 18:31:12 2008
New Revision: 22619

URL: http://svn.erp5.org?rev=22619&view=rev
Log:
Unify clone behaviour between usual clone and clone in erp5_web.

Modified:
    erp5/trunk/products/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/Base_createCloneDocument.xml

Modified: erp5/trunk/products/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/Base_createCloneDocument.xml
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/Base_createCloneDocument.xml?rev=22619&r1=22618&r2=22619&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/Base_createCloneDocument.xml (original)
+++ erp5/trunk/products/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/Base_createCloneDocument.xml Tue Jul 22 18:31:12 2008
@@ -71,12 +71,9 @@
 \n
   Pretty messages are provided to the user.\n
 """\n
-\n
 translateString =  context.Base_translateString\n
 form_data = context.REQUEST.form\n
 \n
-# First make sure that no document already exists with the\n
-# same portal_type, reference, language and version.\n
 if clone:\n
   portal_type = context.getPortalType()\n
 else:\n
@@ -93,6 +90,15 @@
 \n
 # prepare query params\n
 kw = {\'portal_type\' : translateString(portal_type)}\n
+\n
+if web_mode:\n
+  script = getattr(context, "Base_checkCloneConsistency", None)\n
+  if script is not None:\n
+    msg = script(**form_data)\n
+    if msg is not None:\n
+      return context.Base_redirect(form_id, \n
+                          editable_mode=editable_mode,\n
+                          keep_items={\'portal_status_message\': msg})\n
 \n
 # Standard cloning method\n
 if clone:\n
@@ -106,10 +112,25 @@
   new_object = directory[paste_result[0][\'new_id\']]\n
   message_kind = \'Clone\'\n
 \n
+if web_mode:\n
+  # Edit the objects with some properties\n
+  # Define a list of field name to take into account in the cloning process\n
+  ACCEPTABLE_FORM_ID_LIST = [ \'clone_reference\' , \'clone_language\'\n
+                             , \'clone_version\' , \'clone_revision\'\n
+                             , \'clone_title\' , \'clone_short_title\' ] \n
+\n
+  # Set properties to the new object\n
+  edit_kw = {}\n
+  property_id_list = new_object.propertyIds()\n
+  for (key, val) in form_data.items():\n
+    if key in ACCEPTABLE_FORM_ID_LIST and key[len(\'clone_\'):] in property_id_list:\n
+      edit_kw[key[len(\'clone_\'):]] = val\n
+  new_object.edit(**edit_kw)\n
+\n
 if batch_mode:\n
   return new_object\n
 else:\n
-  if not editable_mode: \n
+  if web_mode and 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
@@ -131,7 +152,7 @@
         </item>
         <item>
             <key> <string>_params</string> </key>
-            <value> <string>clone=1, form_id, editable_mode=0, batch_mode=0</string> </value>
+            <value> <string>clone=1, form_id, web_mode=0, editable_mode=0, batch_mode=0</string> </value>
         </item>
         <item>
             <key> <string>_proxy_roles</string> </key>
@@ -157,7 +178,7 @@
                   <dictionary>
                     <item>
                         <key> <string>co_argcount</string> </key>
-                        <value> <int>4</int> </value>
+                        <value> <int>5</int> </value>
                     </item>
                     <item>
                         <key> <string>co_varnames</string> </key>
@@ -165,6 +186,7 @@
                           <tuple>
                             <string>clone</string>
                             <string>form_id</string>
+                            <string>web_mode</string>
                             <string>editable_mode</string>
                             <string>batch_mode</string>
                             <string>_getattr_</string>
@@ -178,13 +200,23 @@
                             <string>None</string>
                             <string>kw</string>
                             <string>getattr</string>
+                            <string>script</string>
+                            <string>_apply_</string>
+                            <string>msg</string>
                             <string>directory</string>
                             <string>original_id</string>
                             <string>clipboard</string>
                             <string>paste_result</string>
                             <string>new_object</string>
                             <string>message_kind</string>
-                            <string>msg</string>
+                            <string>ACCEPTABLE_FORM_ID_LIST</string>
+                            <string>edit_kw</string>
+                            <string>property_id_list</string>
+                            <string>_getiter_</string>
+                            <string>key</string>
+                            <string>val</string>
+                            <string>len</string>
+                            <string>_write_</string>
                           </tuple>
                         </value>
                     </item>
@@ -201,6 +233,7 @@
                 <none/>
                 <int>0</int>
                 <int>0</int>
+                <int>0</int>
               </tuple>
             </value>
         </item>




More information about the Erp5-report mailing list