Skip to content

Commit

Permalink
Merge pull request #1295 from okfn/1295-package_list-private-datasets
Browse files Browse the repository at this point in the history
package_list should not return private datasets
  • Loading branch information
kindly committed Nov 4, 2013
2 parents 2ccbea6 + c22b090 commit 5fd8b7a
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
7 changes: 5 additions & 2 deletions ckan/logic/action/get.py
Expand Up @@ -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')
Expand Down
30 changes: 30 additions & 0 deletions ckan/tests/logic/test_action.py
Expand Up @@ -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'

Expand Down

0 comments on commit 5fd8b7a

Please sign in to comment.