From 579d829bbf2c860559808494fb3a54ddca22f604 Mon Sep 17 00:00:00 2001
From: Nicolas Delaby <nicolas@nexedi.com>
Date: Fri, 10 Sep 2010 16:22:11 +0000
Subject: [PATCH] Generate a reference for all events.

This reference is generated with help of short title of portal_type as prefix.
If short title is not filled, all capital letters of portal_type string will be used.

*The computation of this reference will probably be delegated to a specific tool like portal_ids.*

Add read-only field on Event_view to display the reference
add additional column in listbox of Event Module

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@38274 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../EventModule_viewEventList/listbox.xml     | 66 ++++++++-----
 .../portal_skins/erp5_crm/Event_init.xml      | 45 +++++++--
 .../portal_skins/erp5_crm/Event_view.xml      |  6 +-
 .../erp5_crm/Event_view/my_reference.xml      | 96 +++++++++++++++++++
 bt5/erp5_crm/bt/revision                      |  2 +-
 5 files changed, 180 insertions(+), 35 deletions(-)
 create mode 100644 bt5/erp5_crm/SkinTemplateItem/portal_skins/erp5_crm/Event_view/my_reference.xml

diff --git a/bt5/erp5_crm/SkinTemplateItem/portal_skins/erp5_crm/EventModule_viewEventList/listbox.xml b/bt5/erp5_crm/SkinTemplateItem/portal_skins/erp5_crm/EventModule_viewEventList/listbox.xml
index 4004821262..40a3640cfc 100644
--- a/bt5/erp5_crm/SkinTemplateItem/portal_skins/erp5_crm/EventModule_viewEventList/listbox.xml
+++ b/bt5/erp5_crm/SkinTemplateItem/portal_skins/erp5_crm/EventModule_viewEventList/listbox.xml
@@ -2,10 +2,7 @@
 <ZopeData>
   <record id="1" aka="AAAAAAAAAAE=">
     <pickle>
-      <tuple>
-        <global name="ListBox" module="Products.ERP5Form.ListBox"/>
-        <tuple/>
-      </tuple>
+      <global name="ListBox" module="Products.ERP5Form.ListBox"/>
     </pickle>
     <pickle>
       <dictionary>
@@ -415,6 +412,10 @@
                           <string>title</string>
                           <string>Title</string>
                         </tuple>
+                        <tuple>
+                          <string>reference</string>
+                          <string>Reference</string>
+                        </tuple>
                         <tuple>
                           <string>translated_portal_type</string>
                           <string>Event Type</string>
@@ -452,6 +453,10 @@
                     <key> <string>css_class</string> </key>
                     <value> <string></string> </value>
                 </item>
+                <item>
+                    <key> <string>default_display_style</string> </key>
+                    <value> <string>table</string> </value>
+                </item>
                 <item>
                     <key> <string>default_params</string> </key>
                     <value>
@@ -462,6 +467,12 @@
                     <key> <string>description</string> </key>
                     <value> <string></string> </value>
                 </item>
+                <item>
+                    <key> <string>display_style_list</string> </key>
+                    <value>
+                      <list/>
+                    </value>
+                </item>
                 <item>
                     <key> <string>domain_root_list</string> </key>
                     <value>
@@ -499,6 +510,14 @@
                     <key> <string>external_validator</string> </key>
                     <value> <string></string> </value>
                 </item>
+                <item>
+                    <key> <string>full_text_search_key</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>full_text_search_key_script</string> </key>
+                    <value> <string></string> </value>
+                </item>
                 <item>
                     <key> <string>global_attributes</string> </key>
                     <value>
@@ -533,6 +552,10 @@
                       <list/>
                     </value>
                 </item>
+                <item>
+                    <key> <string>page_navigation_mode</string> </key>
+                    <value> <string>slider</string> </value>
+                </item>
                 <item>
                     <key> <string>page_template</string> </key>
                     <value> <string></string> </value>
@@ -569,6 +592,10 @@
                           <string>title</string>
                           <string>Title</string>
                         </tuple>
+                        <tuple>
+                          <string>reference</string>
+                          <string>Reference</string>
+                        </tuple>
                         <tuple>
                           <string>translated_portal_type</string>
                           <string>Event Type</string>
@@ -651,6 +678,12 @@
                     <key> <string>stat_method</string> </key>
                     <value> <string></string> </value>
                 </item>
+                <item>
+                    <key> <string>style_columns</string> </key>
+                    <value>
+                      <list/>
+                    </value>
+                </item>
                 <item>
                     <key> <string>title</string> </key>
                     <value> <string>Events</string> </value>
@@ -675,10 +708,7 @@
   </record>
   <record id="2" aka="AAAAAAAAAAI=">
     <pickle>
-      <tuple>
-        <global name="TALESMethod" module="Products.Formulator.TALESField"/>
-        <tuple/>
-      </tuple>
+      <global name="TALESMethod" module="Products.Formulator.TALESField"/>
     </pickle>
     <pickle>
       <dictionary>
@@ -691,10 +721,7 @@
   </record>
   <record id="3" aka="AAAAAAAAAAM=">
     <pickle>
-      <tuple>
-        <global name="TALESMethod" module="Products.Formulator.TALESField"/>
-        <tuple/>
-      </tuple>
+      <global name="TALESMethod" module="Products.Formulator.TALESField"/>
     </pickle>
     <pickle>
       <dictionary>
@@ -707,10 +734,7 @@
   </record>
   <record id="4" aka="AAAAAAAAAAQ=">
     <pickle>
-      <tuple>
-        <global name="TALESMethod" module="Products.Formulator.TALESField"/>
-        <tuple/>
-      </tuple>
+      <global name="TALESMethod" module="Products.Formulator.TALESField"/>
     </pickle>
     <pickle>
       <dictionary>
@@ -723,10 +747,7 @@
   </record>
   <record id="5" aka="AAAAAAAAAAU=">
     <pickle>
-      <tuple>
-        <global name="Method" module="Products.Formulator.MethodField"/>
-        <tuple/>
-      </tuple>
+      <global name="Method" module="Products.Formulator.MethodField"/>
     </pickle>
     <pickle>
       <dictionary>
@@ -739,10 +760,7 @@
   </record>
   <record id="6" aka="AAAAAAAAAAY=">
     <pickle>
-      <tuple>
-        <global name="Method" module="Products.Formulator.MethodField"/>
-        <tuple/>
-      </tuple>
+      <global name="Method" module="Products.Formulator.MethodField"/>
     </pickle>
     <pickle>
       <dictionary>
diff --git a/bt5/erp5_crm/SkinTemplateItem/portal_skins/erp5_crm/Event_init.xml b/bt5/erp5_crm/SkinTemplateItem/portal_skins/erp5_crm/Event_init.xml
index bc041447b7..c98864964d 100644
--- a/bt5/erp5_crm/SkinTemplateItem/portal_skins/erp5_crm/Event_init.xml
+++ b/bt5/erp5_crm/SkinTemplateItem/portal_skins/erp5_crm/Event_init.xml
@@ -2,10 +2,7 @@
 <ZopeData>
   <record id="1" aka="AAAAAAAAAAE=">
     <pickle>
-      <tuple>
-        <global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
-        <tuple/>
-      </tuple>
+      <global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
     </pickle>
     <pickle>
       <dictionary>
@@ -53,8 +50,25 @@
         </item>
         <item>
             <key> <string>_body</string> </key>
-            <value> <string># Set preferred text format\n
-context.edit(content_type=context.portal_preferences.getPreferredTextFormat())\n
+            <value> <string># XXX Reference will be probably generated with dedicated tool\n
+# in near future\n
+\n
+portal = context.getPortalObject()\n
+portal_type = context.getPortalType()\n
+type_definition = portal.portal_types[portal_type]\n
+\n
+short_portal_type = type_definition.getShortTitle()\n
+if not short_portal_type:\n
+  short_portal_type = \'\'.join([s for s in portal_type if s.isupper()])\n
+\n
+id_group = (\'reference\', short_portal_type)\n
+default = 1\n
+new_id = context.generateNewId(id_group=id_group, default=default)\n
+reference = \'%s-%s\' % (short_portal_type, new_id)\n
+\n
+# Set preferred text format and reference\n
+context.edit(content_type=context.portal_preferences.getPreferredTextFormat(),\n
+             reference=reference)\n
 </string> </value>
         </item>
         <item>
@@ -67,6 +81,12 @@ context.edit(content_type=context.portal_preferences.getPreferredTextFormat())\n
             <key> <string>_params</string> </key>
             <value> <string>*args, **kw</string> </value>
         </item>
+        <item>
+            <key> <string>_proxy_roles</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
         <item>
             <key> <string>errors</string> </key>
             <value>
@@ -95,6 +115,19 @@ context.edit(content_type=context.portal_preferences.getPreferredTextFormat())\n
                             <string>kw</string>
                             <string>_getattr_</string>
                             <string>context</string>
+                            <string>portal</string>
+                            <string>portal_type</string>
+                            <string>_getitem_</string>
+                            <string>type_definition</string>
+                            <string>short_portal_type</string>
+                            <string>append</string>
+                            <string>$append0</string>
+                            <string>_getiter_</string>
+                            <string>s</string>
+                            <string>id_group</string>
+                            <string>default</string>
+                            <string>new_id</string>
+                            <string>reference</string>
                           </tuple>
                         </value>
                     </item>
diff --git a/bt5/erp5_crm/SkinTemplateItem/portal_skins/erp5_crm/Event_view.xml b/bt5/erp5_crm/SkinTemplateItem/portal_skins/erp5_crm/Event_view.xml
index ff7c177dea..3fa21adeb9 100644
--- a/bt5/erp5_crm/SkinTemplateItem/portal_skins/erp5_crm/Event_view.xml
+++ b/bt5/erp5_crm/SkinTemplateItem/portal_skins/erp5_crm/Event_view.xml
@@ -2,10 +2,7 @@
 <ZopeData>
   <record id="1" aka="AAAAAAAAAAE=">
     <pickle>
-      <tuple>
-        <global name="ERP5Form" module="Products.ERP5Form.Form"/>
-        <tuple/>
-      </tuple>
+      <global name="ERP5Form" module="Products.ERP5Form.Form"/>
     </pickle>
     <pickle>
       <dictionary>
@@ -98,6 +95,7 @@
                     <value>
                       <list>
                         <string>my_title</string>
+                        <string>my_reference</string>
                         <string>my_start_date</string>
                         <string>my_translated_portal_type</string>
                         <string>my_resource</string>
diff --git a/bt5/erp5_crm/SkinTemplateItem/portal_skins/erp5_crm/Event_view/my_reference.xml b/bt5/erp5_crm/SkinTemplateItem/portal_skins/erp5_crm/Event_view/my_reference.xml
new file mode 100644
index 0000000000..b184a3f86d
--- /dev/null
+++ b/bt5/erp5_crm/SkinTemplateItem/portal_skins/erp5_crm/Event_view/my_reference.xml
@@ -0,0 +1,96 @@
+<?xml version="1.0"?>
+<ZopeData>
+  <record id="1" aka="AAAAAAAAAAE=">
+    <pickle>
+      <global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>delegated_list</string> </key>
+            <value>
+              <list>
+                <string>editable</string>
+              </list>
+            </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>my_reference</string> </value>
+        </item>
+        <item>
+            <key> <string>message_values</string> </key>
+            <value>
+              <dictionary>
+                <item>
+                    <key> <string>external_validator_failed</string> </key>
+                    <value> <string>The input failed the external validator.</string> </value>
+                </item>
+              </dictionary>
+            </value>
+        </item>
+        <item>
+            <key> <string>overrides</string> </key>
+            <value>
+              <dictionary>
+                <item>
+                    <key> <string>field_id</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>form_id</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>target</string> </key>
+                    <value> <string></string> </value>
+                </item>
+              </dictionary>
+            </value>
+        </item>
+        <item>
+            <key> <string>tales</string> </key>
+            <value>
+              <dictionary>
+                <item>
+                    <key> <string>field_id</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>form_id</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>target</string> </key>
+                    <value> <string></string> </value>
+                </item>
+              </dictionary>
+            </value>
+        </item>
+        <item>
+            <key> <string>values</string> </key>
+            <value>
+              <dictionary>
+                <item>
+                    <key> <string>editable</string> </key>
+                    <value> <int>0</int> </value>
+                </item>
+                <item>
+                    <key> <string>field_id</string> </key>
+                    <value> <string>my_reference</string> </value>
+                </item>
+                <item>
+                    <key> <string>form_id</string> </key>
+                    <value> <string>Base_viewFieldLibrary</string> </value>
+                </item>
+                <item>
+                    <key> <string>target</string> </key>
+                    <value> <string>Click to edit the target</string> </value>
+                </item>
+              </dictionary>
+            </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
diff --git a/bt5/erp5_crm/bt/revision b/bt5/erp5_crm/bt/revision
index 34c3a209c7..e1170b6414 100644
--- a/bt5/erp5_crm/bt/revision
+++ b/bt5/erp5_crm/bt/revision
@@ -1 +1 @@
-487
\ No newline at end of file
+489
\ No newline at end of file
-- 
2.30.9