diff --git a/product/CMFCategory/Category.py b/product/CMFCategory/Category.py index 5cf4622e94e3e429d2fd9b2b0606ba9da7dc9c50..c6cd7d56d4f048fe2bbc0dcf65d3c2777c4af497 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 1e546edea800a0a6b6b5f4f68f34a1dc451967ec..a70799af9df78ac137f55bab592448db0cd8f1db 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 4b0ea51308e39040f3bb1d9eba1f493af49a8dd7..341c22e294df35a188bbef8de860d2ba03e8b374 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')