diff --git a/ckanext/odsh/plugin.py b/ckanext/odsh/plugin.py index f7c323f47a9256303822bf853e81a6f58bf8bf4b..41af53d1100203add3e8b9bdbd4314675ab64e99 100644 --- a/ckanext/odsh/plugin.py +++ b/ckanext/odsh/plugin.py @@ -84,7 +84,7 @@ class OdshPlugin(plugins.SingletonPlugin, DefaultTranslation, DefaultDatasetForm # bp_user.add_url_rule(u'/user/register', view_func=user.register) bp_user.add_url_rule(u'/user/activity/<id>', view_func=user.activity) bp_user.add_url_rule(u'/user/activity/<id>/<int:offset>', view_func=user.activity) - + # Dashboard bp_dashboard = dashboard.blueprint bp_dashboard.add_url_rule( @@ -96,9 +96,11 @@ class OdshPlugin(plugins.SingletonPlugin, DefaultTranslation, DefaultDatasetForm bp_dashboard.add_url_rule( u'/dashboard/datasets', view_func=dashboard.dashboard_datasets) - # + # Harvest bp_harvest = harvest.blueprint - bp_harvest.add_url_rule(u'/harvest/new', view_func=dashboard.new) + bp_harvest.add_url_rule(u'/harvest/new', view_func=harvest.new) + bp_harvest.add_url_rule(u'/harvest', view_func=harvest.search) + return [bp_default, bp_package, bp_user, bp_dashboard, bp_harvest] # IActions diff --git a/ckanext/odsh/views/harvest.py b/ckanext/odsh/views/harvest.py index 832f4eabbfeb103711653e35b9b1c6b141124693..fdf79427728caf7e6c288f70ba2a6120d44549fe 100644 --- a/ckanext/odsh/views/harvest.py +++ b/ckanext/odsh/views/harvest.py @@ -1,13 +1,26 @@ import ckan.plugins.toolkit as toolkit +import ckan.authz as authz from flask import Blueprint -from ckan.views.dataset import CreateView +import ckan.views.dataset as dataset +from ckan.common import g import logging log = logging.getLogger(__name__) -blueprint = Blueprint('odsh_default', __name__) +blueprint = Blueprint('odsh_harvest', __name__) def new(): - log.info("views.harvest::new") - return CreateView.as_view(str(u'new')) - #toolkit.abort(404) \ No newline at end of file + log.debug("views.harvest::new") + is_sysadmin = authz.is_sysadmin(g.user) + + if not is_sysadmin: + toolkit.abort(403) + return dataset.CreateView.as_view(str(u'new'))('harvest') + +def search(): + log.debug("views.harvest::search") + is_sysadmin = authz.is_sysadmin(g.user) + + if not is_sysadmin: + toolkit.abort(403) + return dataset.search('harvest')