From 9cc0f849b32301be98669d5b725ebc48b305b7f1 Mon Sep 17 00:00:00 2001 From: Sean Hammond Date: Fri, 26 Oct 2012 14:36:19 +0200 Subject: [PATCH] [#1664] Add group activity stream page You can now see a group's activity stream at /group/activity/GROUP_NAME. This page is not integrated into the rest of the group pages yet like the user activity stream page is with the user pages, but can be in future if we want. Also remove c.group_activity_stream from the group read context as it's not used so no need to compute it. --- ckan/config/routing.py | 3 ++- ckan/controllers/group.py | 28 ++++++++++++++++++----- ckan/templates/group/activity_stream.html | 6 +++++ 3 files changed, 30 insertions(+), 7 deletions(-) create mode 100644 ckan/templates/group/activity_stream.html diff --git a/ckan/config/routing.py b/ckan/config/routing.py index 3558098be33..b2bcc28721e 100644 --- a/ckan/config/routing.py +++ b/ckan/config/routing.py @@ -237,7 +237,8 @@ def make_map(): 'edit', 'authz', 'delete', - 'history' + 'history', + 'activity', ])) ) m.connect('group_read', '/group/{id}', action='read') diff --git a/ckan/controllers/group.py b/ckan/controllers/group.py index 5a1dcdb7aa8..189381d7ec4 100644 --- a/ckan/controllers/group.py +++ b/ckan/controllers/group.py @@ -233,12 +233,6 @@ def pager_url(q=None, page=None): c.facets = {} c.page = h.Page(collection=[]) - # 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')(context, - {'id': c.group_dict['id']}) - return render(self._read_template(c.group_dict['type'])) def new(self, data=None, errors=None, error_summary=None): @@ -498,6 +492,28 @@ def history(self, id): return feed.writeString('utf-8') return render(self._history_template(c.group_dict['type'])) + def activity(self, id): + '''Render this group's public activity stream page.''' + + 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'] + except NotFound: + abort(404, _('Group not found')) + except NotAuthorized: + abort(401, _('Unauthorized to read group %s') % id) + + # 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')( + context, {'id': c.group_dict['id']}) + + return render('group/activity_stream.html') + def _render_edit_form(self, fs): # errors arrive in c.error and fs.errors c.fieldset = fs diff --git a/ckan/templates/group/activity_stream.html b/ckan/templates/group/activity_stream.html new file mode 100644 index 00000000000..8543d0d8a3a --- /dev/null +++ b/ckan/templates/group/activity_stream.html @@ -0,0 +1,6 @@ +{% extends "page.html" %} + +{% block primary_content %} +

{{ _('Activity Stream') }}

+ {{ c.group_activity_stream | safe }} +{% endblock %}