[ckan-changes] [okfn/ckan] de6872: [#2304] Add followers tab to dataset pages

GitHub noreply at github.com
Tue Apr 24 10:22:41 UTC 2012


  Branch: refs/heads/feature-2304-follow
  Home:   https://github.com/okfn/ckan
  Commit: de68721851bc45f474c76146605b6cab8dd42275
      https://github.com/okfn/ckan/commit/de68721851bc45f474c76146605b6cab8dd42275
  Author: Sean Hammond <seanhammond at lavabit.com>
  Date:   2012-04-24 (Tue, 24 Apr 2012)

  Changed paths:
    M ckan/config/routing.py
    M ckan/controllers/package.py
    A ckan/templates/package/followers.html
    M ckan/templates/package/layout.html

  Log Message:
  -----------
  [#2304] Add followers tab to dataset pages


diff --git a/ckan/config/routing.py b/ckan/config/routing.py
index 7a0df71..fa08e2c 100644
--- a/ckan/config/routing.py
+++ b/ckan/config/routing.py
@@ -178,6 +178,7 @@ def make_map():
           'history',
           'read_ajax',
           'history_ajax',
+          'followers',
           ]))
           )
         m.connect('/dataset/{id}.{format}', action='read')
diff --git a/ckan/controllers/package.py b/ckan/controllers/package.py
index 286c151..51e7a62 100644
--- a/ckan/controllers/package.py
+++ b/ckan/controllers/package.py
@@ -749,3 +749,18 @@ def resource_read(self, id, resource_id):
                 qualified=True)
         return render('package/resource_read.html')
 
+    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.pkg_dict = get_action('package_show')(context, data_dict)
+            c.pkg = context['package']
+            c.followers = get_action('dataset_follower_list')(context,
+                    {'id': c.pkg_dict['id']})
+        except NotFound:
+            abort(404, _('Dataset not found'))
+        except NotAuthorized:
+            abort(401, _('Unauthorized to read package %s') % id)
+
+        return render('package/followers.html')
diff --git a/ckan/templates/package/followers.html b/ckan/templates/package/followers.html
new file mode 100644
index 0000000..727dd3b
--- /dev/null
+++ b/ckan/templates/package/followers.html
@@ -0,0 +1,22 @@
+<html xmlns:py="http://genshi.edgewall.org/"
+  xmlns:i18n="http://genshi.edgewall.org/i18n"
+  xmlns:xi="http://www.w3.org/2001/XInclude"
+  py:strip="">
+
+  <py:def function="page_title">${c.pkg_dict.get('title', c.pkg_dict['name'])} - Datasets - Followers</py:def>
+  <py:def function="page_heading">Followers: ${c.pkg.title or c.pkg.name}</py:def>
+  <py:def function="body_class">no-sidebar</py:def>
+
+  <div py:match="content" class="dataset">
+    <h3>Followers</h3>
+    <ul class="userlist">
+     <li py:for="follower in c.followers" class="user">
+        <ul>
+          ${h.linked_user(follower['name'], maxlength=20)}
+        </ul>
+      </li>
+    </ul>
+  </div>
+
+  <xi:include href="layout.html" />
+</html>
diff --git a/ckan/templates/package/layout.html b/ckan/templates/package/layout.html
index 2751557..fbc8ab5 100644
--- a/ckan/templates/package/layout.html
+++ b/ckan/templates/package/layout.html
@@ -35,6 +35,7 @@
       </py:otherwise>
       </py:choose>
       <li class="${'active' if c.action=='history' else ''}">${h.subnav_link(h.icon('page_stack') + _('History'), controller='package', action='history', id=c.pkg.name)}</li>
+      <li class="${'active' if c.action=='followers' else ''}">${h.subnav_link(h.icon('authorization_group') + _('Followers'), controller='package', action='followers', id=c.pkg.name)}</li>
       <py:if test="h.check_access('package_update',{'id':c.pkg.id})">
         <li class="divider">|</li>
         <li class="${'active' if c.action=='edit' else ''}">


================================================================



More information about the ckan-changes mailing list