Skip to content

Commit

Permalink
Merge pull request #3056 from k-nut/2859-abort-400-if-validation-erro…
Browse files Browse the repository at this point in the history
…r-in-activity-view

Catch validation error in actvity lists
  • Loading branch information
wardi committed May 26, 2016
2 parents 18ed5d6 + 75b0c1d commit a2e8665
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
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
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

0 comments on commit a2e8665

Please sign in to comment.