Commit fd081eb1 authored by Romain Courteaud's avatar Romain Courteaud

Use CMFCategory/Renderer to render item lists.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@2769 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent da0be207
...@@ -30,6 +30,7 @@ from AccessControl import ClassSecurityInfo ...@@ -30,6 +30,7 @@ from AccessControl import ClassSecurityInfo
from Globals import InitializeClass from Globals import InitializeClass
from Products.ERP5Type import Context, Interface, Permissions from Products.ERP5Type import Context, Interface, Permissions
from Products.ERP5Type.Base import Base from Products.ERP5Type.Base import Base
from Products.CMFCategory.Renderer import Renderer
class Variated(Base): class Variated(Base):
""" """
...@@ -54,40 +55,49 @@ class Variated(Base): ...@@ -54,40 +55,49 @@ class Variated(Base):
# Declarative interfaces # Declarative interfaces
__implements__ = (Interface.Variated, ) __implements__ = (Interface.Variated, )
security.declareProtected(Permissions.AccessContentsInformation, '_getVariationCategoryList') security.declareProtected(Permissions.AccessContentsInformation,
'_getVariationCategoryList')
def _getVariationCategoryList(self, base_category_list = ()): def _getVariationCategoryList(self, base_category_list = ()):
if base_category_list is (): if base_category_list is ():
base_category_list = self.getVariationRangeBaseCategoryList() base_category_list = self.getVariationRangeBaseCategoryList()
return self.getAcquiredCategoryMembershipList(base_category_list,base=1) return self.getAcquiredCategoryMembershipList(base_category_list, base=1)
security.declareProtected(Permissions.AccessContentsInformation, 'getVariationCategoryList') security.declareProtected(Permissions.AccessContentsInformation,
def getVariationCategoryList(self, base_category_list = ()): 'getVariationCategoryList')
def getVariationCategoryList(self, base_category_list=()):
""" """
Returns the list of possible variations Returns the list of possible variations
""" """
return self._getVariationCategoryList(base_category_list = base_category_list) return self._getVariationCategoryList(
base_category_list=base_category_list)
security.declareProtected(Permissions.AccessContentsInformation,
'getVariationCategoryItemList')
security.declareProtected(Permissions.AccessContentsInformation, 'getVariationCategoryItemList') def getVariationCategoryItemList(self, base_category_list=(), base=1,
def getVariationCategoryItemList(self, base_category_list = (), base=1, display_id='logical_path',
display_id='getTitle', current_category=None): display_base_category=1,
current_category=None):
""" """
Returns the list of possible variations Returns the list of possible variations
""" """
variation_category_item_list = [] variation_category_item_list = []
if current_category is not None: if current_category is not None:
variation_category_item_list.append((current_category,current_category)) variation_category_item_list.append((current_category,current_category))
variation_category_list = self.getVariationCategoryList(base_category_list=base_category_list)
for variation_category in variation_category_list: if base_category_list is ():
resource = self.portal_categories.resolveCategory(variation_category) base_category_list = self.getVariationRangeBaseCategoryList()
value = getattr(resource, display_id)() for base_category in base_category_list:
if base: variation_category_list = self._getVariationCategoryList(
label = variation_category base_category_list=[base_category])
else: variation_list = map(lambda x: self.portal_categories.resolveCategory(x),
index = variation_category.find('/') + 1 variation_category_list)
label = variation_category[index:] variation_category_item_list.extend(Renderer(
variation_category_item_list.append((label, label)) # We do not know if value is on left or right display_base_category=display_base_category,
display_none_category=0, base=base,
current_category=current_category,
display_id=display_id).\
render(variation_list))
return variation_category_item_list return variation_category_item_list
def getVariationCategoryTitleOrIdItemList(self, base_category_list=(), base=1, **kw): def getVariationCategoryTitleOrIdItemList(self, base_category_list=(), base=1, **kw):
...@@ -95,7 +105,7 @@ class Variated(Base): ...@@ -95,7 +105,7 @@ class Variated(Base):
Returns a list of tuples by parsing recursively all categories in a Returns a list of tuples by parsing recursively all categories in a
given list of base categories. Uses getTitleOrId as method given list of base categories. Uses getTitleOrId as method
""" """
return self.getVariationCategoryItemList(display_id='getTitleOrId', base_category_list=base_category_list, base=base, **kw) return self.getVariationCategoryItemList(display_id='title_or_id', base_category_list=base_category_list, base=base, **kw)
security.declareProtected(Permissions.ModifyPortalContent, '_setVariationCategoryList') security.declareProtected(Permissions.ModifyPortalContent, '_setVariationCategoryList')
def _setVariationCategoryList(self, node_list, base_category_list = ()): def _setVariationCategoryList(self, node_list, base_category_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