Commit 160ac101 authored by Alexandre Boeglin's avatar Alexandre Boeglin

getVariationCategoryItemList:

- add support for omit_optional_variation parameter
- add backwards compatibility for omit_individual_variation parameter handling


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@20357 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent a73f8889
...@@ -154,6 +154,7 @@ class Resource(XMLMatrix, Variated): ...@@ -154,6 +154,7 @@ class Resource(XMLMatrix, Variated):
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getVariationCategoryItemList') 'getVariationCategoryItemList')
def getVariationCategoryItemList(self, base_category_list=(), def getVariationCategoryItemList(self, base_category_list=(),
omit_optional_variation=0,
omit_individual_variation=1, base=1, omit_individual_variation=1, base=1,
current_category=None, current_category=None,
display_base_category=1, display_base_category=1,
...@@ -173,8 +174,16 @@ class Resource(XMLMatrix, Variated): ...@@ -173,8 +174,16 @@ class Resource(XMLMatrix, Variated):
self.getVariationBaseCategoryList() self.getVariationBaseCategoryList()
individual_bc_list = self.getIndividualVariationBaseCategoryList() individual_bc_list = self.getIndividualVariationBaseCategoryList()
other_bc_list = [x for x in base_category_list if x not other_bc_list = [x for x in base_category_list
in individual_bc_list] if not x in individual_bc_list]
if omit_optional_variation:
optional_bc_list = self.getOptionalVariationBaseCategoryList()\
or self.getPortalOptionBaseCategoryList()
if optional_bc_list:
other_bc_list = [x for x in other_bc_list
if not x in optional_bc_list]
result = Variated.getVariationCategoryItemList(self, result = Variated.getVariationCategoryItemList(self,
base_category_list=other_bc_list, base_category_list=other_bc_list,
...@@ -189,8 +198,12 @@ class Resource(XMLMatrix, Variated): ...@@ -189,8 +198,12 @@ class Resource(XMLMatrix, Variated):
for variation in individual_variation_list: for variation in individual_variation_list:
for base_category in variation.getVariationBaseCategoryList(): for base_category in variation.getVariationBaseCategoryList():
if (base_category_list is () or base_category in # backwards compatbility: if individual_bc_list is empty, allow
base_category_list) and base_category in individual_bc_list: # all individual variation base categories.
if (base_category_list is ()
or base_category in base_category_list)\
and (not len(individual_bc_list)
or base_category in individual_bc_list):
# XXX append object, relative_url ? # XXX append object, relative_url ?
# XXX now, call Renderer a lot of time. # XXX now, call Renderer a lot of time.
# Better implementation needed # Better implementation needed
......
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