Commit 5ad31e47 authored by Jérome Perrin's avatar Jérome Perrin

local_sort_id and local_sort_method were not passed recursivly, so only the

first level was sorted correctly (and the test was also wrong).



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@14670 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 61653bc6
......@@ -254,8 +254,8 @@ class Category(Folder):
child_value_list = self.objectValues(self.allowed_types)
if local_sort_id:
local_sort_method = lambda a, b: cmp(a.getProperty(local_sort_id),
b.getProperty(local_sort_id))
local_sort_method = lambda a, b: cmp(a.getProperty(local_sort_id, 0),
b.getProperty(local_sort_id, 0))
if local_sort_method:
# sort objects at the current level
child_value_list = list(child_value_list)
......@@ -715,18 +715,22 @@ class BaseCategory(Category):
child_value_list = self.objectValues(self.allowed_types)
if local_sort_id:
local_sort_method = lambda a, b: cmp(a.getProperty(local_sort_id),
b.getProperty(local_sort_id))
local_sort_method = lambda a, b: cmp(a.getProperty(local_sort_id, 0),
b.getProperty(local_sort_id, 0))
if local_sort_method:
# sort objects at the current level
child_value_list = list(child_value_list)
child_value_list.sort(local_sort_method)
LOG('self %s' % self, 0, (local_sort_id, local_sort_method))
if recursive:
for c in child_value_list:
value_list.extend(c.getCategoryChildValueList(recursive=1,
is_self_excluded=0,
include_if_child=include_if_child))
include_if_child=include_if_child,
local_sort_id=local_sort_id,
local_sort_method=local_sort_method))
else:
for c in child_value_list:
if include_if_child:
......
......@@ -879,7 +879,7 @@ class TestCMFCategory(ERP5TypeTestCase):
# here c1, c2, c3 are sorted by their int_index
self.assertEquals(list(bc.getCategoryChildValueList(
local_sort_id='int_index')),
[c1, c11, c111, c12, c3, c2])
[c1, c12, c11, c111, c3, c2])
# here c11 & c12 are sorted by their titles
self.assertEquals(list(c1.getCategoryChildValueList(
local_sort_id='int_index')), [c12, c11, c111])
......
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