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 @@ +
+ {% if notes != 'null' %} +

+ {{ h.truncate(description, length=160, whole_word=True) }} +

+ {% endif %} +
+ {{ h.follow_button('group', id) }} + + + View Group + +
+
+
+
{{ _('Followers') }}
+
{{ num_followers }}
+
+
+
{{ _('Datasets') }}
+
{{ num_datasets }}
+
+
+
diff --git a/ckan/templates/group/admins.html b/ckan/templates/group/admins.html new file mode 100644 index 00000000000..28b480ac65d --- /dev/null +++ b/ckan/templates/group/admins.html @@ -0,0 +1,10 @@ +{% extends "group/read.html" %} + +{% block subtitle %}{{ _('Administrators') }} - {{ c.group_dict.title or c.group_dict.name }}{% endblock %} + +{% block primary_content_inner %} +
+

{{ _('Administrators') }}

+ {% snippet "user/snippets/followers.html", followers=c.admins %} +
+{% endblock %} diff --git a/ckan/templates/group/followers.html b/ckan/templates/group/followers.html index 521a1e0f87d..04089a4d68b 100644 --- a/ckan/templates/group/followers.html +++ b/ckan/templates/group/followers.html @@ -1,8 +1,8 @@ -{% extends "page.html" %} +{% extends "group/read.html" %} {% block subtitle %}{{ _('Followers') }} - {{ c.group_dict.title or c.group_dict.name }}{% endblock %} -{% block primary_content %} +{% block primary_content_inner %}

{{ _('Followers') }}

{% snippet "user/snippets/followers.html", followers=c.followers %} diff --git a/ckan/templates/group/read.html b/ckan/templates/group/read.html index 30160499aab..0405b3c67f5 100644 --- a/ckan/templates/group/read.html +++ b/ckan/templates/group/read.html @@ -8,33 +8,69 @@ {% endblock %} {% block actions_content %} - {% if h.check_access('group_update', {'id': c.group.id}) %} + {% if h.check_access('group_update', {'id': c.group_dict.id}) %}
  • {% link_for _('Add Dataset to Group'), controller='package', action='new', group=c.group_dict.id, class_='btn', icon='plus' %}
  • -
  • {% link_for _('Edit'), controller='group', action='edit', id=c.group_dict.name, class_='btn', icon='cog' %}
  • +
  • {% link_for _('Edit'), controller='group', action='edit', id=c.group_dict.name, class_='btn', icon='wrench' %}
  • {% endif %} - {#
  • {% link_for _('History'), controller='group', action='history', id=c.group_dict.name, class_='btn', icon='undo' %}
  • #} +
  • {{ h.follow_button('group', c.group_dict.id) }}
  • {% endblock %} {% block primary_content %}
    -
    - {% include "package/snippets/search_form.html" %} -
    - {{ c.page.pager(q=c.q) }} + {% block package_header %} + + {% endblock %} + {% block primary_content_inner %} +
    + {% include "package/snippets/search_form.html" %} +
    + {{ c.page.pager(q=c.q) }} + {% endblock %}
    {% endblock %} {% block secondary_content %} - {% snippet 'snippets/group.html', group=c.group_dict %} - -
    -

    {{ _('Administrators') }}

    - -
    +
    +
    +
    + + {{ c.group_dict.name }} + +
    +

    {{ c.group_dict.display_name }}

    + {% if c.group_dict.description %} + {% if truncate %} +

    {{ c.group_dict.description }}

    + {% else %} +

    {{ h.markdown_extract(c.group_dict.description, truncate) }}

    + {% endif %} + {% else %} +

    {{ _('There is no description for this group') }}

    + {% endif %} +
    +
    +
    {{ _('Followers') }}
    +
    {{ c.group_dict.num_followers }}
    +
    +
    +
    {{ _('Datasets') }}
    +
    {{ c.group_dict.packages|length }}
    +
    +
    +
    +
    {{ h.snippet('snippets/facet_list.html', title='Tags', name='tags', extras={'id':c.group_dict.id}) }} {{ h.snippet('snippets/facet_list.html', title='Formats', name='res_format', extras={'id':c.group_dict.id}) }} diff --git a/ckan/templates/user/read.html b/ckan/templates/user/read.html index 5b6923ce567..8b00ee5a9d1 100644 --- a/ckan/templates/user/read.html +++ b/ckan/templates/user/read.html @@ -74,11 +74,11 @@

    {{ user.fullname or _('No full name provided') }}

    {% endif %}
    -
    +
    {{ _('Followers') }}
    {{ user.num_followers }}
    -
    +
    {{ _('Datasets') }}
    {{ user.number_administered_packages }}