Skip to content

Commit

Permalink
[#3022] Show relevant dataset types on the search pages
Browse files Browse the repository at this point in the history
When visiting the search page of a custom dataset type (eg /<my-type>),
only datasets from this type are shown. On the main search page
(/dataset), only standard datasets are shown, unless the config option
`ckan.search.show_all_types` is set to True.
  • Loading branch information
amercader committed Dec 5, 2012
1 parent 5525d3d commit 17d99a8
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
12 changes: 11 additions & 1 deletion ckan/controllers/package.py
Expand Up @@ -6,6 +6,7 @@
from pylons.i18n import _
from genshi.template import MarkupTemplate
from genshi.template.text import NewTextTemplate
from paste.deploy.converters import asbool

from ckan.logic import get_action, check_access
from ckan.lib.helpers import date_str_to_datetime
Expand Down Expand Up @@ -213,9 +214,18 @@ def pager_url(q=None, page=None):
context = {'model': model, 'session': model.Session,
'user': c.user or c.author, 'for_view': True}

if package_type and package_type != 'dataset':
# Only show datasets of this particular type
fq += ' +dataset_type:{type}'.format(type=package_type)
else:
# Unless changed via config options, don't show non standard
# dataset types on the default search page
if not asbool(config.get('ckan.search.show_all_types','False')):
fq += ' +dataset_type:dataset'

data_dict = {
'q': q,
'fq': fq,
'fq': fq.strip(),
'facet.field': g.facets,
'rows': limit,
'start': (page - 1) * limit,
Expand Down
13 changes: 13 additions & 0 deletions doc/configuration.rst
Expand Up @@ -536,6 +536,19 @@ Default value: ``true``

Make ckan commit changes solr after every dataset update change. Turn this to false if on solr 4.0 and you have automatic (soft)commits enabled to improve dataset update/create speed (however there may be a slight delay before dataset gets seen in results).

ckan.search.show_all_types
^^^^^^^^^^^^^^^^^^^^^^^^^^

Example::

ckan.search.show_all_types = true

Default value: ``false``

Controls whether the default search page (``/dataset``) should show only
standard datasets or also custom dataset types. Default is to show only
standard datasets.

simple_search
^^^^^^^^^^^^^

Expand Down

0 comments on commit 17d99a8

Please sign in to comment.