diff --git a/ckan/controllers/package.py b/ckan/controllers/package.py
index 4806f259b68..b3afe6b9a52 100644
--- a/ckan/controllers/package.py
+++ b/ckan/controllers/package.py
@@ -710,6 +710,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/controllers/user.py b/ckan/controllers/user.py
index 7402f6ae486..862ef2ed61c 100644
--- a/ckan/controllers/user.py
+++ b/ckan/controllers/user.py
@@ -14,7 +14,7 @@
import ckan.lib.navl.dictization_functions as dictization_functions
import ckan.plugins as p
-from ckan.common import _, c, g, request
+from ckan.common import _, c, g, request, response
log = logging.getLogger(__name__)
@@ -216,20 +216,12 @@ def _save_new(self, context):
error_summary = e.error_summary
return self.new(data_dict, errors, error_summary)
if not c.user:
- # Redirect to a URL picked up by repoze.who which performs the
- # login
- login_url = self._get_repoze_handler('login_handler_path')
-
- # We need to pass the logged in URL as came_from parameter
- # otherwise we lose the language setting
- came_from = h.url_for(controller='user', action='logged_in',
- __ckan_no_root=True)
- redirect_url = '{0}?login={1}&password={2}&came_from={3}'
- h.redirect_to(redirect_url.format(
- login_url,
- str(data_dict['name']),
- quote(data_dict['password1'].encode('utf-8')),
- came_from))
+ # log the user in programatically
+ rememberer = request.environ['repoze.who.plugins']['friendlyform']
+ identity = {'repoze.who.userid': data_dict['name']}
+ response.headerlist += rememberer.remember(request.environ,
+ identity)
+ h.redirect_to(controller='user', action='me', __ckan_no_root=True)
else:
# #1799 User has managed to register whilst logged in - warn user
# they are not re-logged in as new user.
diff --git a/ckan/templates/footer.html b/ckan/templates/footer.html
index 6c8373f3ab2..e780c1f63f5 100644
--- a/ckan/templates/footer.html
+++ b/ckan/templates/footer.html
@@ -10,7 +10,7 @@
{% block footer_links_ckan %}
- {% set api_url = 'http://docs.ckan.org/en/{0}/api.html'.format(g.ckan_doc_version) %}
+ {% set api_url = 'http://docs.ckan.org/en/{0}/api/'.format(g.ckan_doc_version) %}
- {{ _('CKAN API') }}
- {{ _('Open Knowledge Foundation') }}
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 %}
diff --git a/ckan/templates_legacy/layout_base.html b/ckan/templates_legacy/layout_base.html
index 50010c0bd22..11818927092 100644
--- a/ckan/templates_legacy/layout_base.html
+++ b/ckan/templates_legacy/layout_base.html
@@ -142,7 +142,7 @@
Twitter @ckanproject
${h.link_to(_('API'), h.url_for(controller='api', action='get_api', ver=1))}
- ${h.link_to(_('API Docs'), 'http://docs.ckan.org/en/latest/api.html')}
+ ${h.link_to(_('API Docs'), 'http://docs.ckan.org/en/latest/api/')}
Contact Us
diff --git a/ckan/templates_legacy/package/search.html b/ckan/templates_legacy/package/search.html
index 9e0128cbc9c..c2527a32a0e 100644
--- a/ckan/templates_legacy/package/search.html
+++ b/ckan/templates_legacy/package/search.html
@@ -35,7 +35,7 @@ Other access
You can also access this registry using the
${h.link_to(_('API'), h.url_for(controller='api', action='get_api', id=None, ver=3))}
- (see ${h.link_to(_('API Docs'), 'http://docs.ckan.org/en/latest/api.html')})
+ (see ${h.link_to(_('API Docs'), 'http://docs.ckan.org/en/latest/api/')})
or download a full ${dumps_format}
dump.
diff --git a/ckanext/example_theme/v16_initialize_a_javascript_module/templates/snippets/package_item.html b/ckanext/example_theme/v16_initialize_a_javascript_module/templates/snippets/package_item.html
index b387c8feb39..dae933e595d 100644
--- a/ckanext/example_theme/v16_initialize_a_javascript_module/templates/snippets/package_item.html
+++ b/ckanext/example_theme/v16_initialize_a_javascript_module/templates/snippets/package_item.html
@@ -1,6 +1,6 @@
{% ckan_extends %}
-{% block package_item_content %}
+{% block content %}
{{ super() }}
{# Use Fanstatic to include our custom JavaScript module.
diff --git a/ckanext/example_theme/v17_popover/templates/snippets/package_item.html b/ckanext/example_theme/v17_popover/templates/snippets/package_item.html
index a53aa78ed67..7d1799c5b6f 100644
--- a/ckanext/example_theme/v17_popover/templates/snippets/package_item.html
+++ b/ckanext/example_theme/v17_popover/templates/snippets/package_item.html
@@ -1,6 +1,6 @@
{% ckan_extends %}
-{% block package_item_content %}
+{% block content %}
{{ super() }}
{% resource 'example_theme/example_theme_popover.js' %}
diff --git a/ckanext/example_theme/v18_snippet_api/templates/snippets/package_item.html b/ckanext/example_theme/v18_snippet_api/templates/snippets/package_item.html
index 163a7f74447..7fad388b7bf 100644
--- a/ckanext/example_theme/v18_snippet_api/templates/snippets/package_item.html
+++ b/ckanext/example_theme/v18_snippet_api/templates/snippets/package_item.html
@@ -1,6 +1,6 @@
{% ckan_extends %}
-{% block package_item_content %}
+{% block content %}
{{ super() }}
{% resource 'example_theme/example_theme_popover.js' %}
diff --git a/ckanext/example_theme/v21_custom_jquery_plugin/templates/snippets/package_item.html b/ckanext/example_theme/v21_custom_jquery_plugin/templates/snippets/package_item.html
index 75ed673e3c8..8de2288dffd 100644
--- a/ckanext/example_theme/v21_custom_jquery_plugin/templates/snippets/package_item.html
+++ b/ckanext/example_theme/v21_custom_jquery_plugin/templates/snippets/package_item.html
@@ -1,6 +1,6 @@
{% ckan_extends %}
-{% block package_item_content %}
+{% block content %}
{{ super() }}
{% resource 'example_theme/example_theme_popover.js' %}
diff --git a/doc/theming/css.rst b/doc/theming/css.rst
index 0274f6eba70..586e026e119 100644
--- a/doc/theming/css.rst
+++ b/doc/theming/css.rst
@@ -27,8 +27,10 @@ Extensions can add their own CSS files to modify or extend CKAN's default CSS.
Create an ``example_theme.css`` file in your extension's ``public`` directory::
ckanext-example_theme/
- public/
- example_theme.css
+ ckanext/
+ example_theme/
+ public/
+ example_theme.css
Add this CSS into the ``example_theme.css`` file, to change the color of CKAN's
"account masthead" (the bar across the top of the site that shows the logged-in
@@ -46,8 +48,10 @@ we include a CSS file in this base template then the file will be included in
every page of your CKAN site. Create the file::
ckanext-example_theme/
- templates/
- base.html
+ ckanext/
+ example_theme/
+ templates/
+ base.html
and put this Jinja code in it:
diff --git a/doc/theming/fanstatic.rst b/doc/theming/fanstatic.rst
index 35c2528fd24..3fdf90245b5 100644
--- a/doc/theming/fanstatic.rst
+++ b/doc/theming/fanstatic.rst
@@ -28,10 +28,12 @@ to serve the CSS file with Fanstatic.
file from ``public`` into ``fanstatic``::
ckanext-example_theme/
- public/
- promoted-image.jpg
- fanstatic/
- example_theme.css
+ ckanext/
+ example_theme/
+ public/
+ promoted-image.jpg
+ fanstatic/
+ example_theme.css
2. Use CKAN's :py:func:`~ckan.plugins.toolkit.add_resource()` function to
register your fanstatic directory with CKAN. Edit the ``update_config()``
diff --git a/doc/theming/javascript.rst b/doc/theming/javascript.rst
index 04a2a0eb277..f0a763c293c 100644
--- a/doc/theming/javascript.rst
+++ b/doc/theming/javascript.rst
@@ -67,7 +67,7 @@ Initializing a JavaScript module
To get CKAN to call some custom JavaScript code, we need to:
1. Implement a |javascript| module, and register it with CKAN.
- Create the file ``ckanext-example_theme/fanstatic/example_theme_popover.js``, with these
+ Create the file ``ckanext-example_theme/ckanext/example_theme/fanstatic/example_theme_popover.js``, with these
contents:
.. literalinclude:: /../ckanext/example_theme/v16_initialize_a_javascript_module/fanstatic/example_theme_popover.js
@@ -99,7 +99,7 @@ To get CKAN to call some custom JavaScript code, we need to:
``package_item.html`` template snippet to insert our module whenever a
package is rendered as part of a list of packages (for example, on the
dataset search page). Create the file
- ``ckanext-example_theme/templates/snippets/package_item.html`` with these
+ ``ckanext-example_theme/ckanext/example_theme/templates/snippets/package_item.html`` with these
contents:
.. literalinclude:: /../ckanext/example_theme/v16_initialize_a_javascript_module/templates/snippets/package_item.html
diff --git a/doc/theming/static-files.rst b/doc/theming/static-files.rst
index 9ce61a7ea38..f31cb302912 100644
--- a/doc/theming/static-files.rst
+++ b/doc/theming/static-files.rst
@@ -54,10 +54,12 @@ override the ``promoted.html`` template snippet. Create the following directory
and file::
ckanext-example_theme/
- templates/
- home/
- snippets/
- promoted.html
+ ckanext/
+ example_theme/
+ templates/
+ home/
+ snippets/
+ promoted.html
Edit your new ``promoted.html`` snippet, and insert these contents: