allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jetm...@apache.org
Subject [16/23] git commit: [#7278] ticket:612 Add a way to extend details links
Date Wed, 20 Aug 2014 07:10:55 GMT
[#7278] ticket:612 Add a way to extend details links


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/6a941a2c
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/6a941a2c
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/6a941a2c

Branch: refs/heads/je/42cc_7278
Commit: 6a941a2c05a6f6c38b770f8f96350b430b8730b2
Parents: 1e1f6b5
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Tue Aug 5 07:16:39 2014 +0000
Committer: Igor Bondarenko <jetmind2@gmail.com>
Committed: Tue Aug 19 12:31:51 2014 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/site_admin.py                 | 12 +++++++++++-
 Allura/allura/lib/plugin.py                             | 10 ++++++++++
 Allura/allura/templates/site_admin_search_projects.html |  5 +++--
 3 files changed, 24 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/6a941a2c/Allura/allura/controllers/site_admin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/site_admin.py b/Allura/allura/controllers/site_admin.py
index 18f92f7..baa53ae 100644
--- a/Allura/allura/controllers/site_admin.py
+++ b/Allura/allura/controllers/site_admin.py
@@ -34,7 +34,7 @@ from allura.app import SitemapEntry
 from allura.lib import helpers as h
 from allura.lib import validators as v
 from allura.lib.decorators import require_post
-from allura.lib.plugin import SiteAdminExtension
+from allura.lib.plugin import SiteAdminExtension, ProjectRegistrationProvider
 from allura.lib import search
 from allura.lib.security import require_access
 from allura.lib.widgets import form_fields as ffw
@@ -292,6 +292,15 @@ class SiteAdminController(object):
             if match:
                 count = match.hits
                 projects = match.docs
+                pids = [bson.ObjectId(p['id'].split('#')[1]) for p in projects]
+                mongo_projects = {}
+                for p in M.Project.query.find({'_id': {'$in': pids}}):
+                    mongo_projects[str(p._id)] = p
+
+                for i in range(len(projects)):
+                    p = projects[i]
+                    _id = p['id'].split('#')[1]
+                    p['project'] = mongo_projects[_id]
 
         def convert_fields(p):
             # throw the type away (e.g. '_s' from 'url_s')
@@ -313,6 +322,7 @@ class SiteAdminController(object):
             'page': page,
             'limit': limit,
             'additional_fields': aslist(config.get('search.project.additional_fields'), ','),
+            'provider': ProjectRegistrationProvider.get(),
         }
 
 

http://git-wip-us.apache.org/repos/asf/allura/blob/6a941a2c/Allura/allura/lib/plugin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/plugin.py b/Allura/allura/lib/plugin.py
index 6e75edd..7f34559 100644
--- a/Allura/allura/lib/plugin.py
+++ b/Allura/allura/lib/plugin.py
@@ -854,6 +854,16 @@ class ProjectRegistrationProvider(object):
         '''
         return project._id.generation_time
 
+    def details_links(self, project):
+        '''Return list of pairs (url, label) with details
+        about the project.
+        Links will show up at admin project search page
+        '''
+        return [
+           (project.url() + 'admin/groups/', 'Members'),
+           (project.url() + 'admin/audit/', 'Audit Trail'),
+        ]
+
 
 class ThemeProvider(object):
 

http://git-wip-us.apache.org/repos/asf/allura/blob/6a941a2c/Allura/allura/templates/site_admin_search_projects.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/site_admin_search_projects.html b/Allura/allura/templates/site_admin_search_projects.html
index 41f37db..380df15 100644
--- a/Allura/allura/templates/site_admin_search_projects.html
+++ b/Allura/allura/templates/site_admin_search_projects.html
@@ -48,8 +48,9 @@
         <td>{{ p[field] }}</td>
         {% endfor %}
         <td>
-          <a href="{{ p['url'] + 'admin/groups/' }}">Members</a><br>
-          <a href="{{ p['url'] + 'admin/audit/' }}">Audit Trail</a>
+          {% for url, label in provider.details_links(p['project']) %}
+            <a href="{{ url }}">{{ label }}</a><br>
+          {% endfor %}
         </td>
       </tr>
     {% endfor %}


Mime
View raw message