Commit b2289f9a authored by Sebastien Robin's avatar Sebastien Robin

we should be able to specify if we want to display a category if there is sub-categories


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@2384 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 2be93e05
...@@ -170,7 +170,7 @@ class Category(Folder): ...@@ -170,7 +170,7 @@ class Category(Folder):
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getCategoryChildValueList') 'getCategoryChildValueList')
def getCategoryChildValueList(self, recursive=1): def getCategoryChildValueList(self, recursive=1,**kw):
""" """
List the child objects of this category and all its subcategories. List the child objects of this category and all its subcategories.
...@@ -493,11 +493,24 @@ class BaseCategory(Category): ...@@ -493,11 +493,24 @@ class BaseCategory(Category):
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getCategoryChildValueList') 'getCategoryChildValueList')
def getCategoryChildValueList(self, recursive=1): def getCategoryChildValueList(self, recursive=1, include_if_child=1):
""" """
List the child objects of this category and all its subcategories. List the child objects of this category and all its subcategories.
recursive - if set to 1, list recursively recursive - if set to 1, list recursively
include_if_child - if set to 1, then a category is listed even if
has childs. if set to 0, then don't list if child.
for example:
region/europe
region/europe/france
region/europe/germany
...
becomes:
region/europe/france
region/europe/germany
...
""" """
value_list = [] value_list = []
if recursive: if recursive:
...@@ -505,6 +518,10 @@ class BaseCategory(Category): ...@@ -505,6 +518,10 @@ class BaseCategory(Category):
value_list.extend(c.getCategoryChildValueList(recursive = 1)) value_list.extend(c.getCategoryChildValueList(recursive = 1))
else: else:
for c in self.objectValues(self.allowed_types): for c in self.objectValues(self.allowed_types):
if include_if_child:
value_list.append(c)
else:
if len(c.objectValues(self.allowed_types))==0:
value_list.append(c) value_list.append(c)
return value_list return value_list
......
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