From 4d32c239c4d58087991a7108d8ae2f5b1b0c58d6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com>
Date: Thu, 29 Apr 2010 09:37:51 +0000
Subject: [PATCH] extends the role cloning tool to be able to clone to a portal
 type group

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@34848 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../erp5_toolbox/BaseType_copyRoleList.xml    |  19 +-
 .../BaseType_viewCopyRoleListDialog.xml       |   1 +
 .../your_portal_type_group_list.xml           | 277 ++++++++++++++++++
 .../your_portal_type_list.xml                 |   2 +-
 bt5/erp5_forge/bt/revision                    |   2 +-
 5 files changed, 296 insertions(+), 5 deletions(-)
 create mode 100644 bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/BaseType_viewCopyRoleListDialog/your_portal_type_group_list.xml

diff --git a/bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/BaseType_copyRoleList.xml b/bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/BaseType_copyRoleList.xml
index 2eff6d8b9b..ed98344ba2 100644
--- a/bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/BaseType_copyRoleList.xml
+++ b/bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/BaseType_copyRoleList.xml
@@ -57,6 +57,15 @@
 cb_data = context.manage_copyObjects(\n
      ids=[r.getId() for r in context.contentValues(portal_type=\'Role Information\')])\n
 \n
+if portal_type_group_list:\n
+  for ti in context.portal_types.contentValues():\n
+    if ti == context or ti.getId() in portal_type_list:\n
+      continue\n
+    for group in ti.getTypeGroupList():\n
+      if group in portal_type_group_list:\n
+        portal_type_list.append(ti.getId())\n
+        break\n
+\n
 for ti in portal_type_list:\n
   destination_portal_type = context.portal_types[ti]\n
   if remove_existing_roles:\n
@@ -66,7 +75,8 @@ for ti in portal_type_list:\n
   destination_portal_type.manage_pasteObjects(cb_data)\n
  \n
 return context.Base_redirect(form_id,\n
-  keep_items=dict(portal_status_message=translateString(\'Roles copied\')))\n
+  keep_items=dict(portal_status_message=translateString(\'Roles copied in ${type_list}\',\n
+                          mapping=dict(type_list=\', \'.join(portal_type_list)))))\n
 </string> </value>
         </item>
         <item>
@@ -77,7 +87,7 @@ return context.Base_redirect(form_id,\n
         </item>
         <item>
             <key> <string>_params</string> </key>
-            <value> <string>remove_existing_roles, portal_type_list, form_id=\'view\'</string> </value>
+            <value> <string>remove_existing_roles, portal_type_list, portal_type_group_list, form_id=\'view\', **kw</string> </value>
         </item>
         <item>
             <key> <string>errors</string> </key>
@@ -97,7 +107,7 @@ return context.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>
@@ -105,7 +115,9 @@ return context.Base_redirect(form_id,\n
                           <tuple>
                             <string>remove_existing_roles</string>
                             <string>portal_type_list</string>
+                            <string>portal_type_group_list</string>
                             <string>form_id</string>
+                            <string>kw</string>
                             <string>Products.ERP5Type.Message</string>
                             <string>translateString</string>
                             <string>_getattr_</string>
@@ -116,6 +128,7 @@ return context.Base_redirect(form_id,\n
                             <string>r</string>
                             <string>cb_data</string>
                             <string>ti</string>
+                            <string>group</string>
                             <string>_getitem_</string>
                             <string>destination_portal_type</string>
                             <string>dict</string>
diff --git a/bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/BaseType_viewCopyRoleListDialog.xml b/bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/BaseType_viewCopyRoleListDialog.xml
index e4f8c5dd66..fa238cae96 100644
--- a/bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/BaseType_viewCopyRoleListDialog.xml
+++ b/bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/BaseType_viewCopyRoleListDialog.xml
@@ -96,6 +96,7 @@
                     <key> <string>left</string> </key>
                     <value>
                       <list>
+                        <string>your_portal_type_group_list</string>
                         <string>your_portal_type_list</string>
                         <string>your_remove_existing_roles</string>
                       </list>
diff --git a/bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/BaseType_viewCopyRoleListDialog/your_portal_type_group_list.xml b/bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/BaseType_viewCopyRoleListDialog/your_portal_type_group_list.xml
new file mode 100644
index 0000000000..65938417fd
--- /dev/null
+++ b/bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/BaseType_viewCopyRoleListDialog/your_portal_type_group_list.xml
@@ -0,0 +1,277 @@
+<?xml version="1.0"?>
+<ZopeData>
+  <record id="1" aka="AAAAAAAAAAE=">
+    <pickle>
+      <tuple>
+        <global name="MultiListField" module="Products.Formulator.StandardFields"/>
+        <tuple/>
+      </tuple>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>your_portal_type_group_list</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>
+                <item>
+                    <key> <string>required_not_found</string> </key>
+                    <value> <string>Input is required but no input given.</string> </value>
+                </item>
+                <item>
+                    <key> <string>unknown_selection</string> </key>
+                    <value> <string>You selected an item that was not in the list.</string> </value>
+                </item>
+              </dictionary>
+            </value>
+        </item>
+        <item>
+            <key> <string>overrides</string> </key>
+            <value>
+              <dictionary>
+                <item>
+                    <key> <string>alternate_name</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>css_class</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>default</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>description</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>editable</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>enabled</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>external_validator</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>extra</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>extra_item</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>hidden</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>items</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>required</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>size</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>title</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>unicode</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>view_separator</string> </key>
+                    <value> <string></string> </value>
+                </item>
+              </dictionary>
+            </value>
+        </item>
+        <item>
+            <key> <string>tales</string> </key>
+            <value>
+              <dictionary>
+                <item>
+                    <key> <string>alternate_name</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>css_class</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>default</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>description</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>editable</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>enabled</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>external_validator</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>extra</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>extra_item</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>hidden</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>items</string> </key>
+                    <value>
+                      <persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
+                    </value>
+                </item>
+                <item>
+                    <key> <string>required</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>size</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>title</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>unicode</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>view_separator</string> </key>
+                    <value> <string></string> </value>
+                </item>
+              </dictionary>
+            </value>
+        </item>
+        <item>
+            <key> <string>values</string> </key>
+            <value>
+              <dictionary>
+                <item>
+                    <key> <string>alternate_name</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>css_class</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>default</string> </key>
+                    <value>
+                      <list/>
+                    </value>
+                </item>
+                <item>
+                    <key> <string>description</string> </key>
+                    <value> <string>Copy roles to the types members of the selected groups</string> </value>
+                </item>
+                <item>
+                    <key> <string>editable</string> </key>
+                    <value> <int>1</int> </value>
+                </item>
+                <item>
+                    <key> <string>enabled</string> </key>
+                    <value> <int>1</int> </value>
+                </item>
+                <item>
+                    <key> <string>external_validator</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>extra</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>extra_item</string> </key>
+                    <value> <string></string> </value>
+                </item>
+                <item>
+                    <key> <string>hidden</string> </key>
+                    <value> <int>0</int> </value>
+                </item>
+                <item>
+                    <key> <string>items</string> </key>
+                    <value>
+                      <list/>
+                    </value>
+                </item>
+                <item>
+                    <key> <string>required</string> </key>
+                    <value> <int>0</int> </value>
+                </item>
+                <item>
+                    <key> <string>size</string> </key>
+                    <value> <int>5</int> </value>
+                </item>
+                <item>
+                    <key> <string>title</string> </key>
+                    <value> <string>Copy to Portal Types Groups</string> </value>
+                </item>
+                <item>
+                    <key> <string>unicode</string> </key>
+                    <value> <int>0</int> </value>
+                </item>
+                <item>
+                    <key> <string>view_separator</string> </key>
+                    <value> <string encoding="cdata"><![CDATA[
+
+<br />
+
+]]></string> </value>
+                </item>
+              </dictionary>
+            </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+  <record id="2" aka="AAAAAAAAAAI=">
+    <pickle>
+      <tuple>
+        <global name="TALESMethod" module="Products.Formulator.TALESField"/>
+        <tuple/>
+      </tuple>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>_text</string> </key>
+            <value> <string>python: context.getParentValue().newContent(portal_type=\'Base Type\', temp_object=True).getAvailableGroupList()</string> </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
diff --git a/bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/BaseType_viewCopyRoleListDialog/your_portal_type_list.xml b/bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/BaseType_viewCopyRoleListDialog/your_portal_type_list.xml
index 2842e36a55..c1e6e36ce3 100644
--- a/bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/BaseType_viewCopyRoleListDialog/your_portal_type_list.xml
+++ b/bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/BaseType_viewCopyRoleListDialog/your_portal_type_list.xml
@@ -230,7 +230,7 @@
                 </item>
                 <item>
                     <key> <string>required</string> </key>
-                    <value> <int>1</int> </value>
+                    <value> <int>0</int> </value>
                 </item>
                 <item>
                     <key> <string>size</string> </key>
diff --git a/bt5/erp5_forge/bt/revision b/bt5/erp5_forge/bt/revision
index 72b67e0ede..55b22b1aa9 100644
--- a/bt5/erp5_forge/bt/revision
+++ b/bt5/erp5_forge/bt/revision
@@ -1 +1 @@
-579
\ No newline at end of file
+580
\ No newline at end of file
-- 
2.30.9