Skip to content

Commit

Permalink
Merge pull request #1766 from ckan/1766-resource-create-link
Browse files Browse the repository at this point in the history
"Add some resources" link shown to unauthorized users
  • Loading branch information
nigelbabu committed Jun 17, 2014
2 parents baca61b + 4dd3438 commit 3564807
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
5 changes: 5 additions & 0 deletions ckan/controllers/package.py
Expand Up @@ -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'
Expand Down
13 changes: 7 additions & 6 deletions ckan/templates/package/snippets/resources_list.html
Expand Up @@ -21,12 +21,13 @@ <h3>{{ _('Data and Resources') }}</h3>
{% endblock %}
</ul>
{% else %}
<p>
{# Comment out "add some" as action doesn't exist yet #}
{% trans url=h.url_for(controller='package', action='new_resource', id=pkg.name) %}
<p class="empty">This dataset has no data, <a href="{{ url }}">why not add some?</a>
{% endtrans %}
</p>
{% if h.check_access('resource_create', pkg) %}
{% trans url=h.url_for(controller='package', action='new_resource', id=pkg.name) %}
<p class="empty">This dataset has no data, <a href="{{ url }}">why not add some?</a></p>
{% endtrans %}
{% else %}
<p class="empty">{{ _('This dataset has no data') }}</p>
{% endif %}
{% endif %}
{% endblock %}
</section>

0 comments on commit 3564807

Please sign in to comment.