diff --git a/ckan/logic/action/get.py b/ckan/logic/action/get.py index 70326e75317..ca46ac2ff57 100644 --- a/ckan/logic/action/get.py +++ b/ckan/logic/action/get.py @@ -91,8 +91,11 @@ def package_list(context, data_dict): col = (package_revision_table.c.id if api == 2 else package_revision_table.c.name) query = _select([col]) - query = query.where(_and_(package_revision_table.c.state=='active', - package_revision_table.c.current==True)) + query = query.where(_and_( + package_revision_table.c.state=='active', + package_revision_table.c.current==True, + package_revision_table.c.private==False, + )) query = query.order_by(col) limit = data_dict.get('limit') diff --git a/ckan/tests/logic/test_action.py b/ckan/tests/logic/test_action.py index 41c31a469bc..70857c5eda2 100644 --- a/ckan/tests/logic/test_action.py +++ b/ckan/tests/logic/test_action.py @@ -84,6 +84,36 @@ def test_01_package_list(self): assert 'warandpeace' in res['result'] assert 'annakarenina' in res['result'] + def test_01_package_list_private(self): + tests.call_action_api(self.app, 'organization_create', + name='test_org_2', + apikey=self.sysadmin_user.apikey) + + tests.call_action_api(self.app, 'package_create', + name='public_dataset', + owner_org='test_org_2', + apikey=self.sysadmin_user.apikey) + + res = tests.call_action_api(self.app, 'package_list') + + assert len(res) == 3 + assert 'warandpeace' in res + assert 'annakarenina' in res + assert 'public_dataset' in res + + tests.call_action_api(self.app, 'package_create', + name='private_dataset', + owner_org='test_org_2', + private=True, + apikey=self.sysadmin_user.apikey) + + res = tests.call_action_api(self.app, 'package_list') + assert len(res) == 3 + assert 'warandpeace' in res + assert 'annakarenina' in res + assert 'public_dataset' in res + assert not 'private_dataset' in res + def test_01_current_package_list_with_resources(self): url = '/api/action/current_package_list_with_resources'