diff --git a/ckanext/harvest/logic/auth/get.py b/ckanext/harvest/logic/auth/get.py index f0c3564..72d925f 100644 --- a/ckanext/harvest/logic/auth/get.py +++ b/ckanext/harvest/logic/auth/get.py @@ -3,6 +3,19 @@ from ckan.plugins import toolkit as pt from ckanext.harvest.logic.auth import get_job_object + +def auth_allow_anonymous_access(auth_function): + ''' + Local version of the auth_allow_anonymous_access decorator that only + calls the actual toolkit decorator if the CKAN version supports it + ''' + if pt.check_ckan_version(min_version='2.2'): + auth_function = pt.auth_allow_anonymous_access(auth_function) + + return auth_function + + +@auth_allow_anonymous_access def harvest_source_show(context, data_dict): ''' Authorization check for getting the details of a harvest source @@ -29,6 +42,7 @@ def harvest_source_show(context, data_dict): 'msg': pt._('User {0} not authorized to read harvest source {1}') .format(user, source_id)} +@auth_allow_anonymous_access def harvest_source_show_status(context, data_dict): ''' Authorization check for getting the status of a harvest source @@ -37,6 +51,7 @@ def harvest_source_show_status(context, data_dict): ''' return harvest_source_show(context, data_dict) +@auth_allow_anonymous_access def harvest_source_list(context, data_dict): ''' Authorization check for getting a list of harveste sources @@ -91,6 +106,7 @@ def harvest_job_list(context, data_dict): +@auth_allow_anonymous_access def harvest_object_show(context, data_dict): ''' Authorization check for getting the contents of a harvest object @@ -107,6 +123,7 @@ def harvest_object_list(context, data_dict): return {'success': True} +@auth_allow_anonymous_access def harvesters_info_show(context, data_dict): ''' Authorization check for getting information about the available diff --git a/ckanext/harvest/plugin.py b/ckanext/harvest/plugin.py index 6b36bd8..06fa71f 100644 --- a/ckanext/harvest/plugin.py +++ b/ckanext/harvest/plugin.py @@ -84,7 +84,7 @@ class Harvest(p.SingletonPlugin, DefaultDatasetForm): log.error('Harvest source not found for dataset {0}'.format(data_dict['id'])) return data_dict - data_dict['status'] = harvest_logic.action.get.harvest_source_show_status(context, {'id': source.id}) + data_dict['status'] = p.toolkit.get_action('harvest_source_show_status')(context, {'id': source.id}) elif not 'type' in data_dict or data_dict['type'] != DATASET_TYPE_NAME: # This is a normal dataset, check if it was harvested and if so, add