Commit 9a52f787 authored by Romain Courteaud's avatar Romain Courteaud

Bug fix: do not display all categories in getVariationRangeCategoryList when a...

Bug fix: do not display all categories in getVariationRangeCategoryList when a variation is already defined on a resource.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@2744 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 1dc652bc
...@@ -80,22 +80,16 @@ class Resource(XMLMatrix, CoreResource, Variated): ...@@ -80,22 +80,16 @@ class Resource(XMLMatrix, CoreResource, Variated):
""" """
Returns possible variations Returns possible variations
""" """
result = []
if base_category_list is (): if base_category_list is ():
base_category_list = self.getVariationBaseCategoryList() base_category_list = self.getVariationBaseCategoryList()
elif type(base_category_list) is type('a'): elif type(base_category_list) is type('a'):
base_category_list = (base_category_list,) base_category_list = (base_category_list,)
result = []
for c in base_category_list: other_base_category_dict = dict([(i,1) for i in base_category_list])
c_range = self.getCategoryMembershipList(c, base=base)
if len(c_range) > 0:
result += list(map(lambda x: (x,x), c_range))
else:
if root:
# XXX - no idea why we should keep this ? JPS
result += self.portal_categories.unrestrictedTraverse(c).getBaseItemList(base=base)
try: try:
other_variations = self.searchFolder(portal_type = self.getPortalVariationTypeList()) other_variations = self.searchFolder( \
portal_type=self.getPortalVariationTypeList())
except: except:
other_variations = [] other_variations = []
if len(other_variations) > 0: if len(other_variations) > 0:
...@@ -103,19 +97,30 @@ class Resource(XMLMatrix, CoreResource, Variated): ...@@ -103,19 +97,30 @@ class Resource(XMLMatrix, CoreResource, Variated):
o = o_brain.getObject() o = o_brain.getObject()
for v in o.getVariationBaseCategoryList(): for v in o.getVariationBaseCategoryList():
if base_category_list is () or v in base_category_list: if base_category_list is () or v in base_category_list:
other_base_category_dict[v] = 0
display_value = getattr(o, display_id) display_value = getattr(o, display_id)
if callable( display_value ): if callable( display_value ):
display_value = display_value() display_value = display_value()
if base: if base:
# [ ( display, stored value ) ] # [ ( display, stored value ) ]
result += [('%s/%s' % (v, display_value ), '%s/%s' % (v, o.getRelativeUrl()))] result += [('%s/%s' % (v, display_value ), '%s/%s' % (v, o.getRelativeUrl()))]
else: else:
result += [('%s' % display_value , '%s' % o.getRelativeUrl())] result += [('%s' % display_value , '%s' % o.getRelativeUrl())]
return result other_base_category_item_list = filter(lambda x: x[1]==1,
other_base_category_dict.items())
other_base_category_list = map(lambda x: x[0],
other_base_category_item_list)
for c in other_base_category_list:
c_range = self.getCategoryMembershipList(c, base=base)
if len(c_range) > 0:
result += list(map(lambda x: (x,x), c_range))
else:
if root:
# XXX - no idea why we should keep this ? JPS
result += self.portal_categories.unrestrictedTraverse(c).getBaseItemList(base=base)
return result
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
......
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