Skip to content

Commit

Permalink
Added about page to groups and fixed the truncate error on group/read…
Browse files Browse the repository at this point in the history
….html
  • Loading branch information
johnmartin committed Nov 5, 2012
1 parent 3d0361c commit 5a66e8c
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 22 deletions.
1 change: 1 addition & 0 deletions ckan/config/routing.py
Expand Up @@ -242,6 +242,7 @@ def make_map():
'follow',
'unfollow',
'admins',
'about',
'activity',
]))
)
Expand Down
27 changes: 13 additions & 14 deletions ckan/controllers/group.py
Expand Up @@ -551,21 +551,21 @@ def unfollow(self, id):
h.redirect_to(controller='group', action='read', id=id)

def followers(self, id=None):
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.followers = get_action('group_follower_list')(context,
{'id': c.group_dict['id']})
except NotFound:
abort(404, _('Group not found'))
except NotAuthorized:
abort(401, _('Unauthorized to read group %s') % id)

context = self._get_group_dict(id)
c.followers = get_action('group_follower_list')(context,
{'id': c.group_dict['id']})
return render('group/followers.html')

def admins(self, id=None):
context = self._get_group_dict(id)
c.admins = self.authorizer.get_admins(context['group'])
return render('group/admins.html')

def about(self, id=None):
self._get_group_dict(id)
return render('group/about.html')

def _get_group_dict(self, id):
context = {'model': model, 'session': model.Session,
'user': c.user or c.author,
'for_view': True}
Expand All @@ -577,8 +577,7 @@ def admins(self, id=None):
abort(404, _('Group not found'))
except NotAuthorized:
abort(401, _('Unauthorized to read group %s') % id)

return render('group/admins.html')
return context

def _render_edit_form(self, fs):
# errors arrive in c.error and fs.errors
Expand Down
6 changes: 3 additions & 3 deletions ckan/lib/activity_streams.py
Expand Up @@ -161,16 +161,16 @@ def activity_stream_string_new_related_item():
# A dictionary mapping activity types to the icons associated to them
activity_stream_string_icons = {
'added tag': 'tag',
'changed group': 'users',
'changed group': 'group',
'changed package': 'sitemap',
'changed package_extra': 'edit',
'changed resource': 'file',
'changed user': 'user',
'deleted group': 'users',
'deleted group': 'group',
'deleted package': 'sitemap',
'deleted package_extra': 'edit',
'deleted resource': 'file',
'new group': 'users',
'new group': 'group',
'new package': 'sitemap',
'new package_extra': 'edit',
'new resource': 'file',
Expand Down
37 changes: 37 additions & 0 deletions ckan/templates/group/about.html
@@ -0,0 +1,37 @@
{% extends "group/read.html" %}

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

{% block primary_content_inner %}
<section class="module-content">
<h1 class="hide-heading">{{ _('About') }}</h1>
<table class="table">
<col width="10">
<col width="60">
<tbody>
<tr>
<td>Name:</td>
<td>{{ c.group_dict.title or c.group_dict.name }}</td>
</tr>
<tr>
<td>Description:</td>
<td>
{% if c.group_dict.description %}
<p>{{ c.group_dict.description }}</p>
{% else %}
<p class="empty">{{ _('There is no description for this group') }}</p>
{% endif %}
</td>
</tr>
<tr>
<td>URL:</td>
<td>
<a href="{{ h.url_for(controller='group', action='read', id=c.group_dict.name) }}">
{{ h.url_for(controller='group', action='read', id=c.group_dict.name, qualified=true) }}
</a>
</td>
</tr>
</tbody>
</table>
</section>
{% endblock %}
12 changes: 7 additions & 5 deletions ckan/templates/group/read.html
Expand Up @@ -32,6 +32,9 @@
<li{% if c.action == 'admins' %} class="active"{% endif %}>
{% link_for _('Administrators'), controller='group', action='admins', id=c.group_dict.name, icon='cog' %}
</li>
<li{% if c.action == 'about' %} class="active"{% endif %}>
{% link_for _('About'), controller='group', action='about', id=c.group_dict.name, icon='info-sign' %}
</li>
</ul>
</header>
{% endblock %}
Expand All @@ -54,11 +57,10 @@
</div>
<h1 class="heading">{{ c.group_dict.display_name }}</h1>
{% if c.group_dict.description %}
{% if truncate %}
<p>{{ c.group_dict.description }}</p>
{% else %}
<p>{{ h.markdown_extract(c.group_dict.description, truncate) }}</p>
{% endif %}
<p>
{{ h.markdown_extract(c.group_dict.description, 180) }}
{% link_for _('read more'), controller='group', action='about', id=c.group_dict.name %}
</p>
{% else %}
<p class="empty">{{ _('There is no description for this group') }}</p>
{% endif %}
Expand Down

0 comments on commit 5a66e8c

Please sign in to comment.