Commit f77f05d9 authored by Jérome Perrin's avatar Jérome Perrin

added getCategoryChildTranslatedTitleItemList, getCategoryChildTranslatedLogicalPathItemList


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@4453 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent d2fc2527
...@@ -150,7 +150,7 @@ class Category(Folder): ...@@ -150,7 +150,7 @@ class Category(Folder):
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getLogicalPath') 'getLogicalPath')
def getLogicalPath(self): def getLogicalPath(self, item_method = 'getTitle'):
""" """
Returns logical path, starting under base category. Returns logical path, starting under base category.
""" """
...@@ -164,12 +164,18 @@ class Category(Folder): ...@@ -164,12 +164,18 @@ class Category(Folder):
# it s better for the user to display something than only ''... # it s better for the user to display something than only ''...
logical_title_list = [] logical_title_list = []
for object in objectlist: for object in objectlist:
logical_title = object.getTitle() logical_title = getattr(object, item_method)()
if logical_title in [None, '']: if logical_title in [None, '']:
logical_title = object.getId() logical_title = object.getId()
logical_title_list.append(logical_title) logical_title_list.append(logical_title)
return '/'.join(logical_title_list) return '/'.join(logical_title_list)
def getTranslatedLogicalPath(self):
"""
Returns translated logical path, started under base category.
"""
return self.getLogicalPath(item_method='getTranslatedTitle')
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getIndentedTitle') 'getIndentedTitle')
def getIndentedTitle(self): def getIndentedTitle(self):
...@@ -260,6 +266,16 @@ class Category(Folder): ...@@ -260,6 +266,16 @@ class Category(Folder):
""" """
return self.getCategoryChildItemList(recursive = recursive, display_id='title', base=base, **kw) return self.getCategoryChildItemList(recursive = recursive, display_id='title', base=base, **kw)
security.declareProtected(Permissions.AccessContentsInformation,
'getCategoryChildTranslatedTitleItemList')
def getCategoryChildTranslatedTitleItemList(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
"""
return self.getCategoryChildItemList(recursive = recursive,
display_id='translated_title', base=base, **kw)
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getCategoryChildTitleOrIdItemList') 'getCategoryChildTitleOrIdItemList')
def getCategoryChildTitleOrIdItemList(self, recursive=1, base=0, **kw): def getCategoryChildTitleOrIdItemList(self, recursive=1, base=0, **kw):
...@@ -277,6 +293,15 @@ class Category(Folder): ...@@ -277,6 +293,15 @@ class Category(Folder):
given list of base categories. Uses getLogicalPath as default method given list of base categories. Uses getLogicalPath as default method
""" """
return self.getCategoryChildItemList(recursive = recursive, display_id='logical_path', base=base, **kw) return self.getCategoryChildItemList(recursive = recursive, display_id='logical_path', base=base, **kw)
def getCategoryChildTranslatedLogicalPathItemList(self, recursive=1, base=0, **kw):
"""
Returns a list of tuples by parsing recursively all categories in a
given list of base categories. Uses translation of getLogicalPath
as default method
"""
return self.getCategoryChildItemList(recursive = recursive,
display_id='translated_logical_path', base=base, **kw)
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getCategoryChildIndentedTitleItemList') 'getCategoryChildIndentedTitleItemList')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment