diff --git a/ckan/lib/helpers.py b/ckan/lib/helpers.py index af0bb8199e9..71582bac071 100644 --- a/ckan/lib/helpers.py +++ b/ckan/lib/helpers.py @@ -1021,16 +1021,10 @@ def follow_count(obj_type, obj_id): context = {'model': model, 'session': model.Session, 'user': c.user} return logic.get_action(action)(context, {'id': obj_id}) - def _create_url_with_params(params=None, controller=None, action=None, extras=None): ''' internal function for building urls with parameters. ''' - def url_with_params(url, params): - params = [(k, v.encode('utf-8') if isinstance(v, basestring) else \ - str(v)) for k, v in params] - return url + u'?' + urllib.urlencode(params) - if not controller: controller = c.controller if not action: @@ -1039,7 +1033,7 @@ def url_with_params(url, params): extras = {} url = url_for(controller=controller, action=action, **extras) - return url_with_params(url, params) + return _url_with_params(url, params) def add_url_param(alternative_url=None, controller=None, action=None, extras=None, new_params=None): @@ -1050,18 +1044,19 @@ def add_url_param(alternative_url=None, controller=None, action=None, via url_for(controller=controller, action=action, **extras) controller & action default to the current ones ''' + params_nopage = [(k, v) for k, v in request.params.items() if k != 'page'] params = set(params_nopage) if new_params: params |= set(new_params.items()) if alternative_url: - return url_with_params(alternative_url, params) + return _url_with_params(alternative_url, params) return _create_url_with_params(params=params, controller=controller, action=action, extras=extras) def remove_url_param(key, value=None, replace=None, controller=None, - action=None, extras=None): + action=None, extras=None, alternative_url=None): ''' Remove a key from the current parameters. A specific key/value pair can be removed by passing a second value argument otherwise all pairs matching the key will be removed. If replace is given then a @@ -1079,6 +1074,10 @@ def remove_url_param(key, value=None, replace=None, controller=None, [params.remove((k, v)) for (k, v) in params[:] if k == key] if replace is not None: params.append((key, replace)) + + if alternative_url: + return _url_with_params(alternative_url, params) + return _create_url_with_params(params=params, controller=controller, action=action, extras=extras) diff --git a/ckan/templates/snippets/facet_list.html b/ckan/templates/snippets/facet_list.html index 7eb9df13c16..fc1bf87d15b 100644 --- a/ckan/templates/snippets/facet_list.html +++ b/ckan/templates/snippets/facet_list.html @@ -33,7 +33,7 @@

{{ h.get_face