diff --git a/ckan/controllers/package.py b/ckan/controllers/package.py index a7019add4cd..46bb986e90f 100644 --- a/ckan/controllers/package.py +++ b/ckan/controllers/package.py @@ -704,6 +704,11 @@ def new_resource(self, id, data=None, errors=None, error_summary=None): pkg_dict = get_action('package_show')(context, {'id': id}) except NotFound: abort(404, _('The dataset {id} could not be found.').format(id=id)) + try: + check_access('resource_create', context, pkg_dict) + except NotAuthorized: + abort(401, _('Unauthorized to create a resource for this package')) + # required for nav menu vars['pkg_dict'] = pkg_dict template = 'package/new_resource_not_draft.html' diff --git a/ckan/templates/package/snippets/resources_list.html b/ckan/templates/package/snippets/resources_list.html index 4672539cbc3..9eb739284e6 100644 --- a/ckan/templates/package/snippets/resources_list.html +++ b/ckan/templates/package/snippets/resources_list.html @@ -21,12 +21,13 @@

{{ _('Data and Resources') }}

{% endblock %} {% else %} -

- {# Comment out "add some" as action doesn't exist yet #} - {% trans url=h.url_for(controller='package', action='new_resource', id=pkg.name) %} -

This dataset has no data, why not add some? - {% endtrans %} -

+ {% if h.check_access('resource_create', pkg) %} + {% trans url=h.url_for(controller='package', action='new_resource', id=pkg.name) %} +

This dataset has no data, why not add some?

+ {% endtrans %} + {% else %} +

{{ _('This dataset has no data') }}

+ {% endif %} {% endif %} {% endblock %}