Commit 7969c85c authored by Romain Courteaud's avatar Romain Courteaud

Modified getVariationRangeCategoryList, to follow changed made in Resource....

Modified getVariationRangeCategoryList, to follow changed made in Resource. Use CMFCategory/Renderer to display item list.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@2771 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 7b181721
...@@ -43,6 +43,7 @@ from Globals import InitializeClass ...@@ -43,6 +43,7 @@ from Globals import InitializeClass
from Products.PythonScripts.Utility import allow_class from Products.PythonScripts.Utility import allow_class
import string import string
from Products.CMFCategory.Renderer import Renderer
from zLOG import LOG from zLOG import LOG
class Transformation(XMLObject, Domain, Variated): class Transformation(XMLObject, Domain, Variated):
...@@ -87,7 +88,7 @@ class Transformation(XMLObject, Domain, Variated): ...@@ -87,7 +88,7 @@ class Transformation(XMLObject, Domain, Variated):
Check if variation category list of the resource changed and update transformation Check if variation category list of the resource changed and update transformation
and transformation line and transformation line
""" """
self.setVariationBaseCategoryList( self.getVariationBaseCategoryList() ) self.setVariationBaseCategoryList(self.getVariationBaseCategoryList())
transformation_line_list = self.contentValues() transformation_line_list = self.contentValues()
for transformation_line in transformation_line_list: for transformation_line in transformation_line_list:
transformation_line.updateVariationCategoryList() transformation_line.updateVariationCategoryList()
...@@ -121,7 +122,7 @@ class Transformation(XMLObject, Domain, Variated): ...@@ -121,7 +122,7 @@ class Transformation(XMLObject, Domain, Variated):
security.declareProtected(Permissions.AccessContentsInformation,'getVariationRangeCategoryList') security.declareProtected(Permissions.AccessContentsInformation,'getVariationRangeCategoryList')
def getVariationRangeCategoryList(self, base_category_list = ()): def getVariationRangeCategoryList(self, base_category_list=()):
""" """
Returns possible variation category values for the Returns possible variation category values for the
transformation according to the default resource. transformation according to the default resource.
...@@ -136,14 +137,17 @@ class Transformation(XMLObject, Domain, Variated): ...@@ -136,14 +137,17 @@ class Transformation(XMLObject, Domain, Variated):
resource = self.getResourceValue() resource = self.getResourceValue()
if resource != None: if resource != None:
result = resource.getVariationRangeCategoryList(base_category_list) result = resource.getVariationCategoryList(
base_category_list=base_category_list,
omit_individual_variation=0)
else: else:
# No resource is define on transformation. We want to display content of base categories # No resource is define on transformation. We want to display content of base categories
result = self.portal_categories.getCategoryChildList(base_category_list, base=1) result = self.portal_categories.getCategoryChildList(base_category_list, base=1)
return result return result
security.declareProtected(Permissions.AccessContentsInformation,'getVariationRangeCategoryItemList') security.declareProtected(Permissions.AccessContentsInformation,'getVariationRangeCategoryItemList')
def getVariationRangeCategoryItemList(self, base_category_list = ()): def getVariationRangeCategoryItemList(self, base_category_list=(),
display_base_category=1):
""" """
Returns possible variation category values for the Returns possible variation category values for the
transformation according to the default resource. transformation according to the default resource.
...@@ -159,7 +163,10 @@ class Transformation(XMLObject, Domain, Variated): ...@@ -159,7 +163,10 @@ class Transformation(XMLObject, Domain, Variated):
resource = self.getResourceValue() resource = self.getResourceValue()
if resource != None: if resource != None:
result = resource.getVariationRangeCategoryItemList(base_category_list) result = resource.getVariationCategoryItemList(
base_category_list=base_category_list,
omit_individual_variation=0,
display_base_category=display_base_category)
else: else:
# No resource is define on transformation. We want to display content of base categories # No resource is define on transformation. We want to display content of base categories
result = self.portal_categories.getCategoryChildTitleItemList(base_category_list, base=1, display_none_category=0) result = self.portal_categories.getCategoryChildTitleItemList(base_category_list, base=1, display_none_category=0)
...@@ -197,46 +204,45 @@ class Transformation(XMLObject, Domain, Variated): ...@@ -197,46 +204,45 @@ class Transformation(XMLObject, Domain, Variated):
self.reindexObject() self.reindexObject()
security.declareProtected(Permissions.AccessContentsInformation, 'getVariationCategoryItemList') security.declareProtected(Permissions.AccessContentsInformation, 'getVariationCategoryItemList')
def getVariationCategoryItemList(self, base_category_list = (), base=1, display_id='getTitleOrId', current_category=None): def getVariationCategoryItemList(self, base_category_list=(), base=1,
display_id='title',
current_category=None):
""" """
Returns the list of possible variations Returns the list of possible variations
XXX Copied and modified from Variated XXX Copied and modified from Variated
Result is left display. Result is left display.
""" """
variation_category_item_list = [] variation_category_item_list = []
# What is this parameter ?
# if current_category is not None:
# variation_category_item_list.append((current_category,current_category))
if base_category_list == (): if base_category_list == ():
base_category_list = self.getVariationBaseCategoryList() base_category_list = self.getVariationBaseCategoryList()
variation_category_list = self.getVariationCategoryList(base_category_list=base_category_list) for base_category in base_category_list:
variation_category_list = self.getVariationCategoryList(
for variation_category in variation_category_list: base_category_list=[base_category])
resource = self.portal_categories.resolveCategory(variation_category)
resource_list = [self.portal_categories.resolveCategory(x) for x in\
if resource.getPortalType() == 'Category': variation_category_list]
# XXX Category is unusable if only Title is displayed... category_list = [x for x in resource_list \
value = getattr(resource, 'getLogicalPath')() if x.getPortalType() == 'Category']
else: variation_category_item_list.extend(Renderer(
# And displaying LogicalPath for variation is unusable for user... is_right_display=0,
value = getattr(resource, display_id)() display_base_category=1,
display_none_category=0, base=base,
if base: current_category=current_category,
index = variation_category.find('/') display_id='logical_path').\
base_category = variation_category[:index] render(category_list))
label = base_category+'/'+value object_list = [x for x in resource_list \
else: if x.getPortalType() != 'Category']
label = value variation_category_item_list.extend(Renderer(
is_right_display=0,
# Result is left display display_base_category=1,
variation_category_item_list.append((label, variation_category )) base_category=base_category,
display_none_category=0, base=base,
current_category=current_category,
display_id=display_id).\
render(object_list))
return variation_category_item_list return variation_category_item_list
security.declareProtected(Permissions.AccessContentsInformation, 'getAggregatedAmountList') security.declareProtected(Permissions.AccessContentsInformation, 'getAggregatedAmountList')
def getAggregatedAmountList(self, context=None, REQUEST=None, **kw): def getAggregatedAmountList(self, context=None, REQUEST=None, **kw):
""" """
......
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