Skip to content

Commit

Permalink
Merge branch 'master' into 1251-resource-view
Browse files Browse the repository at this point in the history
  • Loading branch information
vitorbaptista committed Jun 23, 2014
2 parents 194d6c1 + 68ab7d5 commit 5dcf7a7
Show file tree
Hide file tree
Showing 14 changed files with 48 additions and 42 deletions.
5 changes: 5 additions & 0 deletions ckan/controllers/package.py
Expand Up @@ -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'
Expand Down
22 changes: 7 additions & 15 deletions ckan/controllers/user.py
Expand Up @@ -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__)

Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion ckan/templates/footer.html
Expand Up @@ -10,7 +10,7 @@
</ul>
<ul class="unstyled">
{% 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) %}
<li><a href="{{ api_url }}">{{ _('CKAN API') }}</a></li>
<li><a href="http://www.okfn.org/">{{ _('Open Knowledge Foundation') }}</a></li>
<li><a href="http://www.opendefinition.org/okd/"><img src="//assets.okfn.org/images/ok_buttons/od_80x15_blue.png"></a></li>
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>
2 changes: 1 addition & 1 deletion ckan/templates_legacy/layout_base.html
Expand Up @@ -142,7 +142,7 @@ <h3 class="widget-title">About ${g.site_title}</h3>
<a href="http://twitter.com/ckanproject">Twitter @ckanproject</a>
</li>
<li>${h.link_to(_('API'), h.url_for(controller='api', action='get_api', ver=1))}</li>
<li>${h.link_to(_('API Docs'), 'http://docs.ckan.org/en/latest/api.html')}</li>
<li>${h.link_to(_('API Docs'), 'http://docs.ckan.org/en/latest/api/')}</li>
<li>
<a href="http://ckan.org/contact/">Contact Us</a>
</li>
Expand Down
2 changes: 1 addition & 1 deletion ckan/templates_legacy/package/search.html
Expand Up @@ -35,7 +35,7 @@ <h2>Other access</h2>
<p>
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')})<py:if test="dumps_url">
(see ${h.link_to(_('API Docs'), 'http://docs.ckan.org/en/latest/api/')})<py:if test="dumps_url">
or download a <a href="${dumps_url}">full ${dumps_format}
dump</a></py:if>.
</p>
Expand Down
@@ -1,6 +1,6 @@
{% ckan_extends %}

{% block package_item_content %}
{% block content %}
{{ super() }}

{# Use Fanstatic to include our custom JavaScript module.
Expand Down
@@ -1,6 +1,6 @@
{% ckan_extends %}

{% block package_item_content %}
{% block content %}
{{ super() }}
{% resource 'example_theme/example_theme_popover.js' %}

Expand Down
@@ -1,6 +1,6 @@
{% ckan_extends %}

{% block package_item_content %}
{% block content %}
{{ super() }}

{% resource 'example_theme/example_theme_popover.js' %}
Expand Down
@@ -1,6 +1,6 @@
{% ckan_extends %}

{% block package_item_content %}
{% block content %}
{{ super() }}

{% resource 'example_theme/example_theme_popover.js' %}
Expand Down
12 changes: 8 additions & 4 deletions doc/theming/css.rst
Expand Up @@ -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
Expand All @@ -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:

Expand Down
10 changes: 6 additions & 4 deletions doc/theming/fanstatic.rst
Expand Up @@ -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()``
Expand Down
4 changes: 2 additions & 2 deletions doc/theming/javascript.rst
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
10 changes: 6 additions & 4 deletions doc/theming/static-files.rst
Expand Up @@ -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:

Expand Down

0 comments on commit 5dcf7a7

Please sign in to comment.