diff --git a/ckan/config/routing.py b/ckan/config/routing.py index 0b4f711d242..9965a60a3a0 100644 --- a/ckan/config/routing.py +++ b/ckan/config/routing.py @@ -241,6 +241,7 @@ def make_map(): 'followers', 'follow', 'unfollow', + 'admins', ])) ) m.connect('group_read', '/group/{id}', action='read') diff --git a/ckan/controllers/group.py b/ckan/controllers/group.py index af7a3699c90..4499114efc4 100644 --- a/ckan/controllers/group.py +++ b/ckan/controllers/group.py @@ -129,8 +129,6 @@ def read(self, id): _("Cannot render description") c.description_formatted = genshi.HTML(error_msg) - c.group_admins = self.authorizer.get_admins(c.group) - context['return_query'] = True limit = 20 @@ -548,6 +546,21 @@ def followers(self, id=None): return render('group/followers.html') + def admins(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.admins = self.authorizer.get_admins(context['group']) + except NotFound: + abort(404, _('Group not found')) + except NotAuthorized: + abort(401, _('Unauthorized to read group %s') % id) + + return render('group/admins.html') + def _render_edit_form(self, fs): # errors arrive in c.error and fs.errors c.fieldset = fs diff --git a/ckan/lib/activity_streams.py b/ckan/lib/activity_streams.py index 8d1d6fea515..9ac8eb9a887 100644 --- a/ckan/lib/activity_streams.py +++ b/ckan/lib/activity_streams.py @@ -32,7 +32,10 @@ def get_snippet_tag(activity, detail): return h.tag_link(detail['data']['tag']) def get_snippet_group(activity, detail): - return h.group_link(activity['data']['group']) + link = h.group_link(activity['data']['group']) + return literal('''%s''' + % (activity['object_id'], link) + ) def get_snippet_extra(activity, detail): return '"%s"' % detail['data']['package_extra']['key'] @@ -176,7 +179,7 @@ def activity_stream_string_new_related_item(): 'deleted related item': 'picture', 'follow dataset': 'sitemap', 'follow user': 'user', - 'follow group': 'groups', + 'follow group': 'group', 'new related item': 'picture', } diff --git a/ckan/lib/helpers.py b/ckan/lib/helpers.py index 711040fa618..91c5a233b03 100644 --- a/ckan/lib/helpers.py +++ b/ckan/lib/helpers.py @@ -887,7 +887,7 @@ def tag_link(tag): def group_link(group): url = url_for(controller='group', action='read', id=group['name']) - return link_to(group['name'], url) + return link_to(group['title'], url) def dump_json(obj, **kw): @@ -963,7 +963,7 @@ def process_names(items): return items # these are the types of objects that can be followed -_follow_objects = ['dataset', 'user'] +_follow_objects = ['dataset', 'user', 'group'] def follow_button(obj_type, obj_id): diff --git a/ckan/public/base/javascript/modules/popover-context.js b/ckan/public/base/javascript/modules/popover-context.js index cdf8ebbc344..e44fafbf6dc 100644 --- a/ckan/public/base/javascript/modules/popover-context.js +++ b/ckan/public/base/javascript/modules/popover-context.js @@ -21,11 +21,13 @@ window.popover_context = { dict: { user: {}, - dataset: {} + dataset: {}, + group: {} }, render: { user: {}, - dataset: {} + dataset: {}, + group: {} } }; @@ -119,7 +121,10 @@ this.ckan.module('popover-context', function($, _) { var type = this.options.type; if (typeof window.popover_context.dict[type][id] == 'undefined') { var client = this.sandbox.client; - var endpoint = ( type == 'user' ) ? 'user_show' : 'package_show'; + var endpoint = type + '_show'; + if (type == 'dataset') { + endpoint = 'package_show'; + } client.call('GET', endpoint, '?id=' + id, this._onHandleData, this._onHandleError); } else { this._onHandleData(window.popover_context.dict[type][id]); @@ -180,6 +185,13 @@ this.ckan.module('popover-context', function($, _) { params.notes = raw.notes; params.num_resources = raw.resources.length; params.num_tags = raw.tags.length; + } else if (type == 'group') { + params.id = raw.id; + params.title = raw.title; + params.name = raw.name; + params.description = raw.description; + params.num_datasets = raw.packages.length; + //params.num_followers = raw.num_followers; } return params; }, diff --git a/ckan/public/base/javascript/resource.config b/ckan/public/base/javascript/resource.config index 6ab490b0633..8db348394b7 100644 --- a/ckan/public/base/javascript/resource.config +++ b/ckan/public/base/javascript/resource.config @@ -31,6 +31,7 @@ ckan = modules/data-viewer.js modules/resource-form.js modules/resource-upload-field.js + modules/follow.js modules/popover-context.js main = diff --git a/ckan/public/base/less/activity.less b/ckan/public/base/less/activity.less index 98a45a49eb7..dd082969542 100644 --- a/ckan/public/base/less/activity.less +++ b/ckan/public/base/less/activity.less @@ -77,4 +77,5 @@ &.follow-dataset i { background-color: @activityColorNeutral; } &.follow-user i { background-color: spin(@activityColorNeutral, 20); } &.new-related-item i { background-color: spin(@activityColorNew, -60); } + &.follow-group i { background-color: spin(@activityColorNew, -50); } } diff --git a/ckan/public/base/less/ckan.less b/ckan/public/base/less/ckan.less index bb837f804cb..21a8d6ab07e 100644 --- a/ckan/public/base/less/ckan.less +++ b/ckan/public/base/less/ckan.less @@ -14,7 +14,6 @@ @import "masthead.less"; @import "footer.less"; @import "profile.less"; -@import "disqus.less"; @import "activity.less"; @import "popover-context.less"; @import "follower-list.less"; diff --git a/ckan/templates/ajax_snippets/popover-context-group.html b/ckan/templates/ajax_snippets/popover-context-group.html new file mode 100644 index 00000000000..b0efe47f502 --- /dev/null +++ b/ckan/templates/ajax_snippets/popover-context-group.html @@ -0,0 +1,24 @@ +
+ {{ h.truncate(description, length=160, whole_word=True) }} +
+ {% endif %} +{{ c.group_dict.description }}
+ {% else %} +{{ h.markdown_extract(c.group_dict.description, truncate) }}
+ {% endif %} + {% else %} +{{ _('There is no description for this group') }}
+ {% endif %} +