Skip to content

Commit

Permalink
[#3385] add include_dataset_count param to group/org show actions
Browse files Browse the repository at this point in the history
  • Loading branch information
wardi committed Jan 3, 2017
1 parent 97da20e commit 01f564e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion ckan/lib/dictization/model_dictize.py
Expand Up @@ -350,7 +350,7 @@ def group_dictize(group, context,
like tags are included unless you specify it in the params.
:param packages_field: determines the format of the `packages` field - can
be `datasets` or None.
be `datasets`, `dataset_count` or None.
'''
assert packages_field in ('datasets', 'dataset_count', None)
if packages_field == 'dataset_count':
Expand Down
22 changes: 16 additions & 6 deletions ckan/logic/action/get.py
Expand Up @@ -1210,8 +1210,12 @@ def _group_or_org_show(context, data_dict, is_org=False):
group = model.Group.get(id)
context['group'] = group

include_datasets = asbool(data_dict.get('include_datasets', False))
packages_field = 'datasets' if include_datasets else 'dataset_count'
if asbool(data_dict.get('include_datasets', False)):
packages_field = 'datasets'
elif asbool(data_dict.get('include_dataset_count', True)):
packages_field = 'dataset_count'
else:
packages_field = None

include_tags = asbool(data_dict.get('include_tags', True))
include_users = asbool(data_dict.get('include_users', True))
Expand Down Expand Up @@ -1275,9 +1279,12 @@ 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
:param include_datasets: include a truncated list of the group's datasets
(optional, default: ``False``)
:type id: boolean
:type include_datasets: boolean
:param include_dataset_count: include the full package_count
(optional, default: ``True``)
:type include_dataset_count: boolean
:param include_extras: include the group's extra fields
(optional, default: ``True``)
:type id: boolean
Expand Down Expand Up @@ -1307,9 +1314,12 @@ 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
:param include_datasets: include a truncated list of the org's datasets
(optional, default: ``False``)
:type id: boolean
:type include_datasets: boolean
:param include_dataset_count: include the full package_count
(optional, default: ``True``)
:type include_dataset_count: boolean
:param include_extras: include the organization's extra fields
(optional, default: ``True``)
:type id: boolean
Expand Down
2 changes: 1 addition & 1 deletion ckan/logic/schema.py
Expand Up @@ -340,7 +340,7 @@ def default_show_group_schema():
schema['created'] = []
schema['display_name'] = []
schema['extras'] = {'__extras': [keep_extras]}
schema['package_count'] = []
schema['package_count'] = [ignore_missing]
schema['packages'] = {'__extras': [keep_extras]}
schema['revision_id'] = []
schema['state'] = []
Expand Down

0 comments on commit 01f564e

Please sign in to comment.