Skip to content

Commit

Permalink
Add activity stream tab to dataset page
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean Hammond authored and tobes committed Nov 27, 2012
1 parent 7f630a9 commit 9bc76a0
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 7 deletions.
1 change: 1 addition & 0 deletions ckan/config/routing.py
Expand Up @@ -194,6 +194,7 @@ def make_map():
'history',
'read_ajax',
'history_ajax',
'activity',
'followers',
'follow',
'unfollow',
Expand Down
27 changes: 20 additions & 7 deletions ckan/controllers/package.py
Expand Up @@ -319,13 +319,6 @@ def read(self, id, format='html'):
c.current_package_id = c.pkg.id
c.related_count = c.pkg.related_count

# Add the package's activity stream (already rendered to HTML) to the
# template context for the package/read.html template to retrieve
# later.
c.package_activity_stream = \
get_action('package_activity_list_html')(
context, {'id': c.current_package_id})

PackageSaver().render_package(c.pkg_dict, context)

template = self._read_template(package_type)
Expand Down Expand Up @@ -1241,6 +1234,26 @@ def followers(self, id=None):

return render('package/followers.html')

def activity(self, id):
'''Render this package'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.pkg_dict = get_action('package_show')(context, data_dict)
c.pkg = context['package']
c.package_activity_stream = get_action(
'package_activity_list_html')(context,
{'id': c.pkg_dict['id']})
c.related_count = c.pkg.related_count
except NotFound:
abort(404, _('Dataset not found'))
except NotAuthorized:
abort(401, _('Unauthorized to read dataset %s') % id)

return render('package/activity.html')

def resource_embedded_dataviewer(self, id, resource_id,
width=500, height=500):
"""
Expand Down
10 changes: 10 additions & 0 deletions ckan/templates/package/activity.html
@@ -0,0 +1,10 @@
{% extends "package/read.html" %}

{% block subtitle %}{{ _('Activity Stream') }} - {{ c.pkg_dict.title or c.pkg_dict.name }}{% endblock %}

{% block package_content %}
<section class="module-content">
<h1 class="hide-heading">{{ _('Activity Stream') }}</h1>
{{ c.package_activity_stream | safe }}
</section>
{% endblock %}
3 changes: 3 additions & 0 deletions ckan/templates/package/read.html
Expand Up @@ -45,6 +45,9 @@
<li{% if c.action == 'read' %} class="active"{% endif %}>
{% link_for _('Dataset'), controller='package', action='read', id=pkg.name, icon='sitemap' %}
</li>
<li{% if c.action == 'activity' %} class="active"{% endif %}>
{% link_for _('Activity Stream'), controller='package', action='activity', id=pkg.name, icon='time' %}
</li>
<li{% if c.action == 'followers' %} class="active"{% endif %}>
{% link_for _('Followers'), controller='package', action='followers', id=pkg.name, icon='group' %}
</li>
Expand Down

0 comments on commit 9bc76a0

Please sign in to comment.