From f9048b313b21f679e6c72d915bd743deb0ade86b Mon Sep 17 00:00:00 2001 From: amercader Date: Tue, 29 Oct 2013 16:50:42 +0000 Subject: [PATCH] [#1298] Fix activity and about organization pages The controller methods didn't use `self._action` which will use the appropiate `group_` or `organization_` action depending on the group type. The `organization_activity_list_html` action hadn't been used at all until now, as there was a syntax error. --- ckan/controllers/group.py | 10 +++------- ckan/logic/action/get.py | 11 ++++++++++- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/ckan/controllers/group.py b/ckan/controllers/group.py index 66bd533fd43..251a1739248 100644 --- a/ckan/controllers/group.py +++ b/ckan/controllers/group.py @@ -752,11 +752,8 @@ def activity(self, id, offset=0): context = {'model': model, 'session': model.Session, 'user': c.user or c.author, 'for_view': True} - data_dict = {'id': id} - try: - c.group_dict = get_action('group_show')(context, data_dict) - c.group = context['group'] + c.group_dict = self._get_group_dict(id) except NotFound: abort(404, _('Group not found')) except NotAuthorized: @@ -766,10 +763,9 @@ def activity(self, id, offset=0): # 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 = get_action('group_activity_list_html')( + c.group_activity_stream = self._action('group_activity_list_html')( context, {'id': c.group_dict['id'], 'offset': offset}) - #return render('group/activity_stream.html') return render(self._activity_template(c.group_dict['type'])) def follow(self, id): @@ -837,7 +833,7 @@ def _get_group_dict(self, id): 'user': c.user or c.author, 'for_view': True} try: - return get_action('group_show')(context, {'id': id}) + return self._action('group_show')(context, {'id': id}) except NotFound: abort(404, _('Group not found')) except NotAuthorized: diff --git a/ckan/logic/action/get.py b/ckan/logic/action/get.py index 70326e75317..6e01d8b3ea6 100644 --- a/ckan/logic/action/get.py +++ b/ckan/logic/action/get.py @@ -2326,7 +2326,16 @@ def organization_activity_list_html(context, data_dict): ''' activity_stream = organization_activity_list(context, data_dict) - return activity_streams.activity_list_to_html(context, activity_stream) + offset = int(data_dict.get('offset', 0)) + extra_vars = { + 'controller': 'organization', + 'action': 'activity', + 'id': data_dict['id'], + 'offset': offset, + } + + return activity_streams.activity_list_to_html(context, activity_stream, + extra_vars) def recently_changed_packages_activity_list_html(context, data_dict): '''Return the activity stream of all recently changed packages as HTML.