Skip to content

Commit

Permalink
[2385] Moved capacity check for search to package_search
Browse files Browse the repository at this point in the history
  • Loading branch information
rossjones committed May 15, 2012
1 parent b55bab9 commit 0473635
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions ckan/controllers/group.py
Expand Up @@ -175,6 +175,7 @@ def pager_url(q=None, page=None):
fq = 'capacity:"public"'
if (c.userobj and c.group and c.userobj.is_in_group(c.group)):
fq = ''
context['ignore_capacity_check'] = True

data_dict = {
'q':q,
Expand Down
1 change: 0 additions & 1 deletion ckan/controllers/package.py
Expand Up @@ -186,7 +186,6 @@ def pager_url(q=None, page=None):
else:
search_extras[param] = value

fq += ' capacity:"public"'
context = {'model': model, 'session': model.Session,
'user': c.user or c.author, 'for_view': True}

Expand Down
10 changes: 10 additions & 0 deletions ckan/logic/action/get.py
Expand Up @@ -804,6 +804,16 @@ def package_search(context, data_dict):
# return a list of package ids
data_dict['fl'] = 'id'


# If this query hasn't come from a controller that has set this flag
# then we should remove any mention of capacity from the fq and
# instead set it to only retrieve public datasets
fq = data_dict.get('fq','')
if not context.get('ignore_capacity_check',False):
fq = ' '.join(p for p in fq.split(' ')
if not 'capacity:' in p)
data_dict['fq'] = fq + ' capacity:"public"'

query = search.query_for(model.Package)
query.run(data_dict)

Expand Down

0 comments on commit 0473635

Please sign in to comment.