Skip to content

Commit

Permalink
[#1295] Don't return private datasets on package_list
Browse files Browse the repository at this point in the history
  • Loading branch information
amercader committed Nov 5, 2013
1 parent 18549aa commit 0979bcd
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions ckan/logic/action/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ def package_list(context, data_dict):
query = model.Session.query(model.PackageRevision)
query = query.filter(model.PackageRevision.state=='active')
query = query.filter(model.PackageRevision.current==True)
query = query.filter(model.PackageRevision.private==False)

packages = query.all()
return [getattr(p, ref_package_by) for p in packages]
Expand Down
31 changes: 31 additions & 0 deletions ckan/tests/logic/test_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import ckan.lib.search as search

from ckan import plugins
from ckan import tests
from ckan.plugins import SingletonPlugin, implements, IPackageController

class TestAction(WsgiAppCase):
Expand Down Expand Up @@ -73,6 +74,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_package_show(self):
anna_id = model.Package.by_name(u'annakarenina').id
postparams = '%s=1' % json.dumps({'id': anna_id})
Expand Down

0 comments on commit 0979bcd

Please sign in to comment.