Commit 4a600eb2 authored by Jérome Perrin's avatar Jérome Perrin

base= parameter to Category.getCategoryChild*ItemList was not tested and not

implemented the way it was documented.
Changed the implementation to match documentation.



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@14677 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 502873f4
......@@ -194,8 +194,7 @@ class Renderer(Filter):
url = value.getRelativeUrl()
if self.base:
if self.base_category:
# Prepend the specified base category to the url.
url = self.base_category + '/' + url
url = '%s/%s' % (self.base_category, url)
else:
# If the base category of this category does not match the guessed
# base category, merely ignore this category.
......@@ -206,6 +205,10 @@ class Renderer(Filter):
# Remove from now, it might be outdated and useless
#if value.getBaseCategoryId() != guessed_base_category:
# continue
# Prepend the specified base category to the url.
if isinstance(self.base, str):
url = '%s/%s' % (self.base, url)
else:
if self.base_category:
# Nothing to do.
......
......@@ -885,6 +885,21 @@ class TestCMFCategory(ERP5TypeTestCase):
local_sort_id='int_index')), [c12, c11, c111])
def test_25_getCategoryChildItemList_base_parameter(self):
pc = self.getCategoriesTool()
bc = pc.newContent(portal_type='Base Category', id='foo')
c1 = bc.newContent(portal_type='Category', id='1', title='C')
self.assertEquals([['', ''], ['C', '1']],
bc.getCategoryChildTitleItemList())
self.assertEquals([['', ''], ['C', '1']],
bc.getCategoryChildTitleItemList(base=0))
self.assertEquals([['', ''], ['C', 'foo/1']],
bc.getCategoryChildTitleItemList(base=1))
self.assertEquals([['', ''], ['C', 'bar/foo/1']],
bc.getCategoryChildTitleItemList(base='bar'))
if __name__ == '__main__':
framework()
else:
......
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