Skip to content

Commit

Permalink
Merge pull request #4987 from bellisk/4420-fix-org-and-group-dataset-…
Browse files Browse the repository at this point in the history
…counts

4420 fix org and group dataset counts
  • Loading branch information
smotornyuk committed Sep 23, 2019
2 parents f2e5bf9 + 1cacaff commit 1e70c73
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ckan/lib/dictization/model_dictize.py
Expand Up @@ -314,9 +314,9 @@ def get_packages_for_this_group(group_, just_the_count=False):
}

if group_.is_organization:
q['fq'] = 'owner_org:"{0}"'.format(group_.id)
q['fq'] = '+owner_org:"{0}"'.format(group_.id)
else:
q['fq'] = 'groups:"{0}"'.format(group_.name)
q['fq'] = '+groups:"{0}"'.format(group_.name)

# Allow members of organizations to see private datasets.
if group_.is_organization:
Expand Down
4 changes: 4 additions & 0 deletions ckan/tests/lib/dictization/test_model_dictize.py
Expand Up @@ -256,7 +256,9 @@ def test_group_dictize_with_package_list_limited_by_config(self):
def test_group_dictize_with_package_count(self):
# group_list_dictize calls it like this by default
group_ = factories.Group()
other_group_ = factories.Group()
factories.Dataset(groups=[{'name': group_['name']}])
factories.Dataset(groups=[{'name': other_group_['name']}])
group_obj = model.Session.query(model.Group).filter_by().first()
context = {'model': model, 'session': model.Session,
'dataset_counts': model_dictize.get_group_dataset_counts()
Expand Down Expand Up @@ -295,7 +297,9 @@ def test_group_dictize_for_org_with_package_list(self):
def test_group_dictize_for_org_with_package_count(self):
# group_list_dictize calls it like this by default
org_ = factories.Organization()
other_org_ = factories.Organization()
factories.Dataset(owner_org=org_['id'])
factories.Dataset(owner_org=other_org_['id'])
org_obj = model.Session.query(model.Group).filter_by().first()
context = {'model': model, 'session': model.Session,
'dataset_counts': model_dictize.get_group_dataset_counts()
Expand Down

0 comments on commit 1e70c73

Please sign in to comment.