From 037e11ee1df788d90d1fee50ec76f93f2a4da00c Mon Sep 17 00:00:00 2001 From: amercader Date: Mon, 9 Dec 2013 16:28:03 +0000 Subject: [PATCH] [#1208] Allow users to not request the dataset listing on group_show --- ckan/controllers/group.py | 4 ++-- ckan/lib/dictization/model_dictize.py | 6 +++--- ckan/logic/action/get.py | 9 +++++++++ 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/ckan/controllers/group.py b/ckan/controllers/group.py index d7b77957ac7..da4902f543a 100644 --- a/ckan/controllers/group.py +++ b/ckan/controllers/group.py @@ -182,7 +182,7 @@ def read(self, id, limit=20): try: # Do not query for the group datasets when dictizing, as they will # be ignored and get requested on the controller anyway - context['include_group_packages'] = False + context['include_datasets'] = False c.group_dict = self._action('group_show')(context, data_dict) c.group = context['group'] except NotFound: @@ -377,7 +377,7 @@ def bulk_process(self, id): try: # Do not query for the group datasets when dictizing, as they will # be ignored and get requested on the controller anyway - context['include_group_packages'] = False + context['include_datasets'] = False c.group_dict = self._action('group_show')(context, data_dict) c.group = context['group'] except NotFound: diff --git a/ckan/lib/dictization/model_dictize.py b/ckan/lib/dictization/model_dictize.py index b5055d1f2b5..9dc4d5e7047 100644 --- a/ckan/lib/dictization/model_dictize.py +++ b/ckan/lib/dictization/model_dictize.py @@ -328,14 +328,14 @@ def group_dictize(group, context): context['with_capacity'] = True - include_packages = context.get('include_group_packages', True) + include_datasets = context.get('include_datasets', True) q = { 'facet': 'false', 'rows': 0, } - if include_packages: + if include_datasets: q['rows'] = 1000 # Only the first 1000 datasets are returned @@ -351,7 +351,7 @@ def group_dictize(group, context): search_results = logic.get_action('package_search')(context, q) - if include_packages: + if include_datasets: result_dict['packages'] = search_results['results'] result_dict['package_count'] = search_results['count'] diff --git a/ckan/logic/action/get.py b/ckan/logic/action/get.py index c720e4c5620..da51486ffd2 100644 --- a/ckan/logic/action/get.py +++ b/ckan/logic/action/get.py @@ -879,6 +879,9 @@ def _group_or_org_show(context, data_dict, is_org=False): group = model.Group.get(id) context['group'] = group + context['include_datasets'] = ( + data_dict.get('include_datasets','true').lower() in ('true', '1')) + if group is None: raise NotFound @@ -923,6 +926,9 @@ def group_show(context, data_dict): :param id: the id or name of the group :type id: string + :param include_datasets: include a list of the group's datasets + (optional, default: ``True``) + :type id: boolean :rtype: dictionary @@ -936,6 +942,9 @@ def organization_show(context, data_dict): :param id: the id or name of the organization :type id: string + :param include_datasets: include a list of the organization's datasets + (optional, default: ``True``) + :type id: boolean :rtype: dictionary