Commit 040c8361 authored by Nicolas Delaby's avatar Nicolas Delaby

Add new displaying Method indented_title_and_id

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@18447 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent a7d9f52b
...@@ -211,6 +211,30 @@ class Category(Folder): ...@@ -211,6 +211,30 @@ class Category(Folder):
logical_title_list.append(logical_title) logical_title_list.append(logical_title)
return ''.join(logical_title_list) return ''.join(logical_title_list)
security.declareProtected(Permissions.AccessContentsInformation,
'getIndentedTitleAndId')
def getIndentedTitleAndId(self, item_method='getTitleAndId'):
"""
Returns title or id, indented from base_category.
"""
path_len = 0
base = self.getBaseCategory()
current = self
while not current is base :
path_len += 1
current = aq_parent(current)
# it s better for the user to display something than only ''...
logical_title_list = []
if path_len >= 2:
logical_title_list.append(' ' * 4 * (path_len - 1))
logical_title = getattr(self, item_method)()
if logical_title in [None, '']:
logical_title = self.getId()
logical_title_list.append(logical_title)
return ''.join(logical_title_list)
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getTranslatedIndentedTitle') 'getTranslatedIndentedTitle')
def getTranslatedIndentedTitle(self): def getTranslatedIndentedTitle(self):
...@@ -430,6 +454,17 @@ class Category(Folder): ...@@ -430,6 +454,17 @@ class Category(Folder):
return self.getCategoryChildItemList(recursive=recursive, return self.getCategoryChildItemList(recursive=recursive,
display_id='indented_title', base=base, **kw) display_id='indented_title', base=base, **kw)
security.declareProtected(Permissions.AccessContentsInformation,
'getCategoryChildIndentedTitleAndIdItemList')
def getCategoryChildIndentedTitleAndIdItemList(self,
recursive=1, base=0, **kw):
"""
Returns a list of tuples by parsing recursively all categories in a
given list of base categories. Uses getIndentedTitle as default method
"""
return self.getCategoryChildItemList(recursive=recursive,
display_id='indented_title_and_id', base=base, **kw)
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getCategoryChildTranslatedIndentedTitleItemList') 'getCategoryChildTranslatedIndentedTitleItemList')
def getCategoryChildTranslatedIndentedTitleItemList(self, def getCategoryChildTranslatedIndentedTitleItemList(self,
...@@ -832,4 +867,3 @@ class BaseCategory(Category): ...@@ -832,4 +867,3 @@ class BaseCategory(Category):
InitializeClass( Category ) InitializeClass( Category )
InitializeClass( BaseCategory ) InitializeClass( BaseCategory )
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