Skip to content

Commit

Permalink
Merge branch 'poc-flask-views' into poc-flask-views.common-url_for
Browse files Browse the repository at this point in the history
  • Loading branch information
amercader committed May 30, 2016
2 parents fe72b99 + 25982ca commit 2623bfa
Show file tree
Hide file tree
Showing 29 changed files with 730 additions and 173 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
@@ -1,4 +1,4 @@
FROM phusion/baseimage:0.9.10
FROM phusion/baseimage:0.9.15
MAINTAINER Open Knowledge

# Disable SSH
Expand Down
13 changes: 9 additions & 4 deletions ckan/controllers/group.py
Expand Up @@ -825,10 +825,15 @@ def activity(self, id, offset=0):
except (NotFound, NotAuthorized):
abort(404, _('Group not found'))

# Add the group's activity stream (already rendered to HTML) to the
# template context for the group/read.html template to retrieve later.
c.group_activity_stream = self._action('group_activity_list_html')(
context, {'id': c.group_dict['id'], 'offset': offset})
try:
# Add the group's activity stream (already rendered to HTML) to the
# template context for the group/read.html
# template to retrieve later.
c.group_activity_stream = self._action('group_activity_list_html')(
context, {'id': c.group_dict['id'], 'offset': offset})

except ValidationError as error:
base.abort(400)

return render(self._activity_template(group_type),
extra_vars={'group_type': group_type})
Expand Down
2 changes: 1 addition & 1 deletion ckan/controllers/package.py
Expand Up @@ -1145,7 +1145,7 @@ def resource_download(self, id, resource_id, filename=None):
abort(404, _('Resource not found'))

if rsc.get('url_type') == 'upload':
upload = uploader.ResourceUpload(rsc)
upload = uploader.get_resource_uploader(rsc)
filepath = upload.get_path(rsc['id'])
fileapp = paste.fileapp.FileApp(filepath)
try:
Expand Down
7 changes: 5 additions & 2 deletions ckan/controllers/user.py
Expand Up @@ -585,8 +585,11 @@ def activity(self, id, offset=0):

self._setup_template_variables(context, data_dict)

c.user_activity_stream = get_action('user_activity_list_html')(
context, {'id': c.user_dict['id'], 'offset': offset})
try:
c.user_activity_stream = get_action('user_activity_list_html')(
context, {'id': c.user_dict['id'], 'offset': offset})
except ValidationError:
base.abort(400)

return render('user/activity_stream.html')

Expand Down
12 changes: 6 additions & 6 deletions ckan/lib/helpers.py
Expand Up @@ -144,13 +144,13 @@ def redirect_to(*args, **kw):
return _redirect_to(url_for(*args, **kw))


@maintain.deprecated('h.url is deprecated please use h.url_for')
@core_helper
def url(*args, **kw):
'''Create url adding i18n information if selected
wrapper for pylons.url'''
locale = kw.pop('locale', None)
my_url = _pylons_default_url(*args, **kw)
return _local_url(my_url, locale=locale, **kw)
'''
Deprecated: please use `url_for` instead
'''
return url_for(*args, **kw)


@core_helper
Expand Down Expand Up @@ -1072,7 +1072,7 @@ def pager_url(page, partial=None, **kwargs):
if routes_dict.get('id'):
kwargs['id'] = routes_dict['id']
kwargs['page'] = page
return url(**kwargs)
return url_for(**kwargs)


class Page(paginate.Page):
Expand Down

0 comments on commit 2623bfa

Please sign in to comment.