Skip to content

Commit

Permalink
[#2579] some refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
tobes committed Jun 21, 2012
1 parent 20eb92d commit 858835c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
6 changes: 3 additions & 3 deletions ckan/controllers/group.py
Expand Up @@ -148,9 +148,9 @@ def search_url(params):

def drill_down_url(**by):
return h.add_url_param(alternative_url=None,
controller='group', action='read',
extras=dict(id=c.group_dict.get('name')),
**by)
controller='group', action='read',
extras=dict(id=c.group_dict.get('name')),
new_params=by)

c.drill_down_url = drill_down_url

Expand Down
3 changes: 2 additions & 1 deletion ckan/controllers/package.py
Expand Up @@ -120,7 +120,8 @@ def search(self):

def drill_down_url(alternative_url=None, **by):
return h.add_url_param(alternative_url=alternative_url,
controller='package', action='search', **by)
controller='package', action='search',
new_params=by)

c.drill_down_url = drill_down_url

Expand Down
9 changes: 5 additions & 4 deletions ckan/lib/helpers.py
Expand Up @@ -891,7 +891,7 @@ def url_with_params(url, params):
return url_with_params(url, params)

def add_url_param(alternative_url=None, controller=None, action=None,
extras=None, **fields):
extras=None, new_params=None):
'''
Adds extra parameters to existing ones
Expand All @@ -901,14 +901,15 @@ def add_url_param(alternative_url=None, controller=None, action=None,
'''
params_nopage = [(k, v) for k,v in request.params.items() if k != 'page']
params = set(params_nopage)
params |= set(fields.items())
if new_params:
params |= set(new_params.items())
if alternative_url:
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):
def remove_url_param(key, value=None, replace=None, controller=None,
action=None, extras=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
Expand Down

0 comments on commit 858835c

Please sign in to comment.