From e0ea2a0d1a8a4fe548cdc2dcbad7b73f42eb9723 Mon Sep 17 00:00:00 2001
From: Vincent Pelletier <vincent@nexedi.com>
Date: Tue, 6 Jun 2017 11:47:35 +0900
Subject: [PATCH] erp5_core: Provide better urls in
 ActivityTool_viewActivityList

Do not put links when no valid link exists. This makes copying values much
easier.
Do provide links to activity context and method.
Also, do not use TALES when it is not needed.
---
 .../ActivityTool_getMessageMethodEditPath.py  |  7 ++
 .../ActivityTool_getMessageMethodEditPath.xml | 62 +++++++++++++++++
 .../erp5_core/ActivityTool_getMessagePath.py  |  1 +
 .../erp5_core/ActivityTool_getMessagePath.xml | 62 +++++++++++++++++
 .../ActivityTool_viewActivityList/listbox.xml | 66 ++++++++++++++-----
 5 files changed, 180 insertions(+), 18 deletions(-)
 create mode 100644 product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ActivityTool_getMessageMethodEditPath.py
 create mode 100644 product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ActivityTool_getMessageMethodEditPath.xml
 create mode 100644 product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ActivityTool_getMessagePath.py
 create mode 100644 product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ActivityTool_getMessagePath.xml

diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ActivityTool_getMessageMethodEditPath.py b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ActivityTool_getMessageMethodEditPath.py
new file mode 100644
index 0000000000..66472c589d
--- /dev/null
+++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ActivityTool_getMessageMethodEditPath.py
@@ -0,0 +1,7 @@
+method_path = context.str_object_path + '/' + context.method_id
+try:
+  method_value = context.getPortalObject().restrictedTraverse(method_path)
+except Exception:
+  return
+if getattr(method_value, 'manage_main', None) is not None:
+  return method_path + '/manage_main'
diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ActivityTool_getMessageMethodEditPath.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ActivityTool_getMessageMethodEditPath.xml
new file mode 100644
index 0000000000..a98b549ff1
--- /dev/null
+++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ActivityTool_getMessageMethodEditPath.xml
@@ -0,0 +1,62 @@
+<?xml version="1.0"?>
+<ZopeData>
+  <record id="1" aka="AAAAAAAAAAE=">
+    <pickle>
+      <global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>Script_magic</string> </key>
+            <value> <int>3</int> </value>
+        </item>
+        <item>
+            <key> <string>_bind_names</string> </key>
+            <value>
+              <object>
+                <klass>
+                  <global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
+                </klass>
+                <tuple/>
+                <state>
+                  <dictionary>
+                    <item>
+                        <key> <string>_asgns</string> </key>
+                        <value>
+                          <dictionary>
+                            <item>
+                                <key> <string>name_container</string> </key>
+                                <value> <string>container</string> </value>
+                            </item>
+                            <item>
+                                <key> <string>name_context</string> </key>
+                                <value> <string>context</string> </value>
+                            </item>
+                            <item>
+                                <key> <string>name_m_self</string> </key>
+                                <value> <string>script</string> </value>
+                            </item>
+                            <item>
+                                <key> <string>name_subpath</string> </key>
+                                <value> <string>traverse_subpath</string> </value>
+                            </item>
+                          </dictionary>
+                        </value>
+                    </item>
+                  </dictionary>
+                </state>
+              </object>
+            </value>
+        </item>
+        <item>
+            <key> <string>_params</string> </key>
+            <value> <string>**kw</string> </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>ActivityTool_getMessageMethodEditPath</string> </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ActivityTool_getMessagePath.py b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ActivityTool_getMessagePath.py
new file mode 100644
index 0000000000..8ad41e185a
--- /dev/null
+++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ActivityTool_getMessagePath.py
@@ -0,0 +1 @@
+return context.str_object_path
diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ActivityTool_getMessagePath.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ActivityTool_getMessagePath.xml
new file mode 100644
index 0000000000..632b045a3a
--- /dev/null
+++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ActivityTool_getMessagePath.xml
@@ -0,0 +1,62 @@
+<?xml version="1.0"?>
+<ZopeData>
+  <record id="1" aka="AAAAAAAAAAE=">
+    <pickle>
+      <global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>Script_magic</string> </key>
+            <value> <int>3</int> </value>
+        </item>
+        <item>
+            <key> <string>_bind_names</string> </key>
+            <value>
+              <object>
+                <klass>
+                  <global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
+                </klass>
+                <tuple/>
+                <state>
+                  <dictionary>
+                    <item>
+                        <key> <string>_asgns</string> </key>
+                        <value>
+                          <dictionary>
+                            <item>
+                                <key> <string>name_container</string> </key>
+                                <value> <string>container</string> </value>
+                            </item>
+                            <item>
+                                <key> <string>name_context</string> </key>
+                                <value> <string>context</string> </value>
+                            </item>
+                            <item>
+                                <key> <string>name_m_self</string> </key>
+                                <value> <string>script</string> </value>
+                            </item>
+                            <item>
+                                <key> <string>name_subpath</string> </key>
+                                <value> <string>traverse_subpath</string> </value>
+                            </item>
+                          </dictionary>
+                        </value>
+                    </item>
+                  </dictionary>
+                </state>
+              </object>
+            </value>
+        </item>
+        <item>
+            <key> <string>_params</string> </key>
+            <value> <string>**kw</string> </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>ActivityTool_getMessagePath</string> </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ActivityTool_viewActivityList/listbox.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ActivityTool_viewActivityList/listbox.xml
index db749631dc..d7d17241ef 100644
--- a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ActivityTool_viewActivityList/listbox.xml
+++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ActivityTool_viewActivityList/listbox.xml
@@ -78,9 +78,7 @@
                 </item>
                 <item>
                     <key> <string>url_columns</string> </key>
-                    <value>
-                      <persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
-                    </value>
+		    <value> <string></string> </value>
                 </item>
               </dictionary>
             </value>
@@ -185,7 +183,7 @@
                 <item>
                     <key> <string>list_method</string> </key>
                     <value>
-                      <persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
+                      <persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
                     </value>
                 </item>
                 <item>
@@ -262,7 +260,52 @@
                 <item>
                     <key> <string>url_columns</string> </key>
                     <value>
-                      <list/>
+                      <list>
+                        <tuple>
+                          <string>delete</string>
+                          <string>ActivityTool_deleteMessage</string>
+                        </tuple>
+                        <tuple>
+                          <string>restart</string>
+                          <string>ActivityTool_restartMessage</string>
+                        </tuple>
+                        <tuple>
+                          <string>uid_activity</string>
+                          <string></string>
+                        </tuple>
+                        <tuple>
+                          <string>str_object_path</string>
+                          <string>ActivityTool_getMessagePath</string>
+                        </tuple>
+                        <tuple>
+                          <string>method_id</string>
+                          <string>ActivityTool_getMessageMethodEditPath</string>
+                        </tuple>
+                        <tuple>
+                          <string>activity_kw</string>
+                          <string></string>
+                        </tuple>
+                        <tuple>
+                          <string>arguments</string>
+                          <string></string>
+                        </tuple>
+                        <tuple>
+                          <string>kw</string>
+                          <string></string>
+                        </tuple>
+                        <tuple>
+                          <string>processing_node</string>
+                          <string></string>
+                        </tuple>
+                        <tuple>
+                          <string>retry</string>
+                          <string></string>
+                        </tuple>
+                        <tuple>
+                          <string>processing</string>
+                          <string></string>
+                        </tuple>
+                      </list>
                     </value>
                 </item>
               </dictionary>
@@ -272,19 +315,6 @@
     </pickle>
   </record>
   <record id="2" aka="AAAAAAAAAAI=">
-    <pickle>
-      <global name="TALESMethod" module="Products.Formulator.TALESField"/>
-    </pickle>
-    <pickle>
-      <dictionary>
-        <item>
-            <key> <string>_text</string> </key>
-            <value> <string>python: [(\'delete\', \'ActivityTool_deleteMessage\'),(\'restart\', \'ActivityTool_restartMessage\')]</string> </value>
-        </item>
-      </dictionary>
-    </pickle>
-  </record>
-  <record id="3" aka="AAAAAAAAAAM=">
     <pickle>
       <global name="Method" module="Products.Formulator.MethodField"/>
     </pickle>
-- 
2.30.9