[ckan-changes] [okfn/ckan] 4dad55: Rename c.new_facets -> c.search_facets
GitHub
noreply at github.com
Wed Apr 18 13:41:35 UTC 2012
Branch: refs/heads/feature-1821-multilingual-extension
Home: https://github.com/okfn/ckan
Commit: 4dad55045a39f1f8aeb588480f169060510cc405
https://github.com/okfn/ckan/commit/4dad55045a39f1f8aeb588480f169060510cc405
Author: Sean Hammond <seanhammond at lavabit.com>
Date: 2012-04-18 (Wed, 18 Apr 2012)
Changed paths:
M ckan/controllers/group.py
M ckan/controllers/package.py
M ckan/lib/helpers.py
M ckan/logic/action/get.py
Log Message:
-----------
Rename c.new_facets -> c.search_facets
This new name is intended to be stable, won't change in the future
('new_facets" wasn't a very good stable name).
diff --git a/ckan/controllers/group.py b/ckan/controllers/group.py
index 87c89cf..24b1d14 100644
--- a/ckan/controllers/group.py
+++ b/ckan/controllers/group.py
@@ -178,7 +178,7 @@ def pager_url(q=None, page=None):
items_per_page=limit
)
c.facets = query['facets']
- c.new_facets = query['new_facets']
+ c.search_facets = query['search_facets']
c.page.items = query['results']
except SearchError, se:
log.error('Group search error: %r', se.args)
diff --git a/ckan/controllers/package.py b/ckan/controllers/package.py
index 63adb13..c3826d9 100644
--- a/ckan/controllers/package.py
+++ b/ckan/controllers/package.py
@@ -185,7 +185,7 @@ def pager_url(q=None, page=None):
items_per_page=limit
)
c.facets = query['facets']
- c.new_facets = query['new_facets']
+ c.search_facets = query['search_facets']
c.page.items = query['results']
except SearchError, se:
log.error('Dataset search error: %r', se.args)
diff --git a/ckan/lib/helpers.py b/ckan/lib/helpers.py
index abfe0bb..8d79600 100644
--- a/ckan/lib/helpers.py
+++ b/ckan/lib/helpers.py
@@ -347,7 +347,7 @@ def unselected_facet_items(facet, limit=10):
match each facet item).
Reads the complete list of facet items for the given facet from
- c.new_facets, and filters out the facet items that the user has already
+ c.search_facets, and filters out the facet items that the user has already
selected.
Arguments:
@@ -355,12 +355,12 @@ def unselected_facet_items(facet, limit=10):
limit -- the max. number of facet items to return.
'''
- if not c.new_facets or \
- not c.new_facets.get(facet) or \
- not c.new_facets.get(facet).get('items'):
+ if not c.search_facets or \
+ not c.search_facets.get(facet) or \
+ not c.search_facets.get(facet).get('items'):
return []
facets = []
- for facet_item in c.new_facets.get(facet)['items']:
+ for facet_item in c.search_facets.get(facet)['items']:
if not len(facet_item['name'].strip()):
continue
if not (facet, facet_item['name']) in request.params.items():
@@ -369,7 +369,7 @@ def unselected_facet_items(facet, limit=10):
def facet_items(*args, **kwargs):
"""
- DEPRECATED: Use the new facet data structure, and `new_facet_items()`
+ DEPRECATED: Use the new facet data structure, and `unselected_facet_items()`
"""
_log.warning('Deprecated function: ckan.lib.helpers:facet_items(). Will be removed in v1.8')
# facet_items() used to need c passing as the first arg
diff --git a/ckan/logic/action/get.py b/ckan/logic/action/get.py
index 3760a2a..93e4120 100644
--- a/ckan/logic/action/get.py
+++ b/ckan/logic/action/get.py
@@ -758,7 +758,7 @@ def package_search(context, data_dict):
new_facet_dict['display_name'] = key_
new_facet_dict['count'] = value_
restructured_facets[key]['items'].append(new_facet_dict)
- search_results['new_facets'] = restructured_facets
+ search_results['search_facets'] = restructured_facets
# check if some extension needs to modify the search results
for item in plugins.PluginImplementations(plugins.IPackageController):
@@ -766,9 +766,9 @@ def package_search(context, data_dict):
# After extensions have had a chance to modify the facets, sort them by
# display name.
- for facet in search_results['new_facets']:
- search_results['new_facets'][facet]['items'] = sorted(
- search_results['new_facets'][facet]['items'],
+ for facet in search_results['search_facets']:
+ search_results['search_facets'][facet]['items'] = sorted(
+ search_results['search_facets'][facet]['items'],
key=lambda facet: facet['display_name'], reverse=True)
return search_results
================================================================
More information about the ckan-changes
mailing list