Skip to content

Commit

Permalink
Merge branch 'related-list-test-failure'
Browse files Browse the repository at this point in the history
  • Loading branch information
amercader committed Jan 8, 2014
2 parents bf5b82e + 9d84549 commit 2c92361
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions ckan/lib/dictization/model_dictize.py
Expand Up @@ -90,8 +90,9 @@ def related_list_dictize(related_list, context):
for res in related_list:
related_dict = related_dictize(res, context)
result_list.append(related_dict)

return result_list
if context.get('sorted'):
return result_list
return sorted(result_list, key=lambda x: x["created"], reverse=True)


def extras_dict_dictize(extras_dict, context):
Expand Down
1 change: 1 addition & 0 deletions ckan/logic/action/get.py
Expand Up @@ -263,6 +263,7 @@ def related_list(context, data_dict=None):
if data_dict.get('featured', False):
related_list = related_list.filter(model.Related.featured == 1)
related_items = related_list.all()
context['sorted'] = True
else:
relateds = model.Related.get_for_dataset(dataset, status='active')
related_items = (r.related for r in relateds)
Expand Down
2 changes: 1 addition & 1 deletion ckan/tests/functional/test_related.py
Expand Up @@ -467,7 +467,7 @@ def test_api_list(self):
r = json.loads(res.body)
assert r['success'] == True, r
assert r['result'][0]['type'] == "idea"
assert r['result'][0]['title'] == "one", r
assert r['result'][0]['title'] == "two", r

p.related.remove(one)
p.related.remove(two)
Expand Down

0 comments on commit 2c92361

Please sign in to comment.