Skip to content

Commit

Permalink
Adds follower and activity stream support to orgs
Browse files Browse the repository at this point in the history
  • Loading branch information
johnmartin authored and tobes committed Mar 6, 2013
1 parent 835f980 commit 428054e
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 1 deletion.
2 changes: 2 additions & 0 deletions ckan/config/routing.py
Expand Up @@ -309,6 +309,8 @@ def make_map():
'about'
]))
)
m.connect('organization_activity', '/organization/activity/{id}',
action='activity', ckan_icon='time')
m.connect('organization_read', '/organization/{id}', action='read')
register_package_plugins(map)
register_group_plugins(map)
Expand Down
6 changes: 5 additions & 1 deletion ckan/controllers/group.py
Expand Up @@ -68,6 +68,9 @@ def _history_template(self, group_type):
def _edit_template(self, group_type):
return lookup_group_plugin(group_type).edit_template()

def _activity_template(self, group_type):
return lookup_group_plugin(group_type).activity_template()

def _admins_template(self, group_type):
return lookup_group_plugin(group_type).admins_template()

Expand Down Expand Up @@ -751,7 +754,8 @@ def activity(self, id, offset=0):
c.group_activity_stream = get_action('group_activity_list_html')(
context, {'id': c.group_dict['id'], 'offset': offset})

return render('group/activity_stream.html')
#return render('group/activity_stream.html')
return render(self._activity_template(c.group_dict['type']))

def follow(self, id):
'''Start following this group.'''
Expand Down
3 changes: 3 additions & 0 deletions ckan/controllers/organization.py
Expand Up @@ -52,5 +52,8 @@ def _history_template(self, group_type):
def _edit_template(self, group_type):
return 'organization/edit.html'

def _activity_template(self, group_type):
return 'organization/activity_stream.html'

def _guess_group_type(self, expecting_name=False):
return 'organization'
7 changes: 7 additions & 0 deletions ckan/lib/plugins.py
Expand Up @@ -370,6 +370,13 @@ def edit_template(self):
"""
return 'group/edit.html'

def activity_template(self):
"""
Returns a string representing the location of the template to be
rendered for the activity stream page
"""
return 'group/activity_stream.html'

def admins_template(self):
"""
Returns a string representing the location of the template to be
Expand Down
10 changes: 10 additions & 0 deletions ckan/templates/organization/activity_stream.html
@@ -0,0 +1,10 @@
{% extends "organization/read_base.html" %}

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

{% block primary_content_inner %}
<section class="module-content">
<h2 class="hide-heading">{{ _('Activity Stream') }}</h2>
{{ c.group_activity_stream | safe }}
</section>
{% endblock %}
4 changes: 4 additions & 0 deletions ckan/templates/organization/read_base.html
Expand Up @@ -12,6 +12,7 @@
<li>{% link_for _('Add Dataset'), controller='package', action='new', group=c.group_dict.id, class_='btn', icon='plus-sign-alt' %}</li>
<li>{% link_for _('Edit'), controller='organization', action='edit', id=c.group_dict.name, class_='btn btn-primary', icon='wrench' %}</li>
{% endif %}
<li>{{ h.follow_button('group', c.group_dict.id) }}</li>
{# <li>{% link_for _('History'), controller='organization', action='history', id=c.group_dict.name, class_='btn', icon='undo' %}</li> #}
{% endblock %}

Expand All @@ -22,6 +23,9 @@
<li{% if c.action == 'read' %} class="active"{% endif %}>
{% link_for _('Datasets'), controller='organization', action='read', id=c.group_dict.name, icon='sitemap' %}
</li>
<li{% if c.action == 'activity' %} class="active"{% endif %}>
{% link_for _('Activity Stream'), controller='organization', action='activity', id=c.group_dict.name, icon='time' %}
</li>
<li{% if c.action == 'about' %} class="active"{% endif %}>
{% link_for _('About'), controller='organization', action='about', id=c.group_dict.name, icon='info-sign' %}
</li>
Expand Down
4 changes: 4 additions & 0 deletions ckan/templates/snippets/organization.html
Expand Up @@ -30,6 +30,10 @@ <h1 class="heading">{{ organization.title or organization.name }}</h1>
{% endif %}
{% if show_nums %}
<div class="nums">
<dl>
<dt>{{ _('Followers') }}</dt>
<dd>{{ h.SI_number_span(organization.num_followers) }}</dd>
</dl>
<dl>
<dt>{{ _('Members') }}</dt>
<dd>{{ h.SI_number_span(organization.members|length) }}</dd>
Expand Down

0 comments on commit 428054e

Please sign in to comment.