diff --git a/README.md b/README.md index ea0c3db..d09867f 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ This CKAN extension allows a user to create private datasets that only certain u Installation ------------ -Install this extension in your CKAN is instance is as easy as intall any other CKAN extension. +Install this extension in your CKAN instance is as easy as intall any other CKAN extension. * Download the source from this GitHub repo. * Activate your virtual environment (generally by running `. /usr/lib/ckan/default/bin/activate`) diff --git a/ckanext/privatedatasets/plugin.py b/ckanext/privatedatasets/plugin.py index b099d4b..6a533a6 100755 --- a/ckanext/privatedatasets/plugin.py +++ b/ckanext/privatedatasets/plugin.py @@ -108,11 +108,18 @@ class PrivateDatasets(p.SingletonPlugin, tk.DefaultDatasetForm): ###################################################################### def get_auth_functions(self): - return {'package_show': auth.package_show, - 'package_update': auth.package_update, - 'resource_show': auth.resource_show, - constants.PACKAGE_ACQUIRED: auth.package_acquired, - constants.ACQUISITIONS_LIST: auth.acquisitions_list} + auth_functions = {'package_show': auth.package_show, + 'package_update': auth.package_update, + # 'resource_show': auth.resource_show, + constants.PACKAGE_ACQUIRED: auth.package_acquired, + constants.ACQUISITIONS_LIST: auth.acquisitions_list} + + # resource_show is not required in CKAN 2.3 because it delegates to + # package_show + if not tk.check_ckan_version(min_version='2.3'): + auth_functions['resource_show'] = auth.resource_show + + return auth_functions ###################################################################### ############################ ICONFIGURER ############################# diff --git a/ckanext/privatedatasets/tests/test_plugin.py b/ckanext/privatedatasets/tests/test_plugin.py index 5c63d26..377dd96 100644 --- a/ckanext/privatedatasets/tests/test_plugin.py +++ b/ckanext/privatedatasets/tests/test_plugin.py @@ -62,13 +62,19 @@ class PluginTest(unittest.TestCase): @parameterized.expand([ ('package_show', plugin.auth.package_show), ('package_update', plugin.auth.package_update), - ('package_show', plugin.auth.package_show), + ('resource_show', plugin.auth.resource_show), + ('resource_show', plugin.auth.resource_show, True, False), ('package_acquired', plugin.auth.package_acquired), ('acquisitions_list', plugin.auth.acquisitions_list) ]) - def test_auth_function(self, function_name, expected_function): + def test_auth_function(self, function_name, expected_function, is_ckan_23=False, expected=True): + plugin.tk.check_ckan_version = MagicMock(return_value=is_ckan_23) auth_functions = self.privateDatasets.get_auth_functions() - self.assertEquals(auth_functions[function_name], expected_function) + + if expected: + self.assertEquals(auth_functions[function_name], expected_function) + else: + self.assertNotIn(function_name, auth_functions) def test_update_config(self): # Call the method