From 8a595e709c77e0cd9e2ea41e55edacda6cb7b151 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com>
Date: Fri, 22 Sep 2006 12:07:47 +0000
Subject: [PATCH] supports getCategoryChildTitleAndIdItemList, which uses
 Zope's title_and_id

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@10242 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/CMFCategory/Category.py              | 12 +++++++++++-
 product/CMFCategory/tests/testCMFCategory.py |  9 +++++++++
 product/ERP5Type/Base.py                     |  7 +++++++
 3 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/product/CMFCategory/Category.py b/product/CMFCategory/Category.py
index 5cf4622e94..c6cd7d56d4 100644
--- a/product/CMFCategory/Category.py
+++ b/product/CMFCategory/Category.py
@@ -288,9 +288,19 @@ class Category(Folder):
     def getCategoryChildTitleOrIdItemList(self, recursive=1, base=0, **kw):
       """
       Returns a list of tuples by parsing recursively all categories in a
-      given list of base categories. Uses getTitle as default method
+      given list of base categories. Uses getTitleOrId as default method
       """
       return self.getCategoryChildItemList(recursive = recursive, display_id='title_or_id', base=base, **kw)
+    
+    security.declareProtected(Permissions.AccessContentsInformation,
+                                       'getCategoryChildTitleAndIdItemList')
+    def getCategoryChildTitleAndIdItemList(self, recursive=1, base=0, **kw):
+      """
+      Returns a list of tuples by parsing recursively all categories in a
+      given list of base categories. Uses title_and_id as default method
+      """
+      return self.getCategoryChildItemList(recursive=recursive,
+                                          display_id='title_and_id', base=base, **kw)
 
     security.declareProtected(Permissions.AccessContentsInformation,
                                                       'getCategoryChildLogicalPathItemList')
diff --git a/product/CMFCategory/tests/testCMFCategory.py b/product/CMFCategory/tests/testCMFCategory.py
index 1e546edea8..a70799af9d 100644
--- a/product/CMFCategory/tests/testCMFCategory.py
+++ b/product/CMFCategory/tests/testCMFCategory.py
@@ -675,6 +675,15 @@ class TestCMFCategory(ERP5TypeTestCase):
                             strict_membership=1,
                             portal_type='Organisation')], [])
 
+  def test_20_CategoryChildTitleAndIdItemList(self, quiet=quiet,
+                                              run=run_all_test):
+    """Tests getCategoryChildTitleAndIdItemList."""
+    base_cat = self.getCategoryTool().newContent(portal_type='Base Category')
+    cat = base_cat.newContent(portal_type='Category',
+                              id='the_id', title='The Title')
+    self.assertEquals([['', ''], ['The Title (the_id)', 'the_id']],
+                       base_cat.getCategoryChildTitleAndIdItemList())
+    
 if __name__ == '__main__':
     framework()
 else:
diff --git a/product/ERP5Type/Base.py b/product/ERP5Type/Base.py
index 4b0ea51308..341c22e294 100644
--- a/product/ERP5Type/Base.py
+++ b/product/ERP5Type/Base.py
@@ -1690,6 +1690,13 @@ class Base( CopyContainer, PortalContent, ActiveObject, Historical, ERP5Property
 
   security.declareProtected( Permissions.View, 'Title' )
   Title = getTitleOrId
+  
+  security.declareProtected(Permissions.AccessContentsInformation,
+                            'getTitleAndId')
+  def getTitleAndId(self):
+    """Returns the title and the id in parenthesis
+    """
+    return self.title_and_id()
 
   # This method allows to sort objects in list is a more reasonable way
   security.declareProtected(Permissions.View, 'getIntId')
-- 
2.30.9