incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [2/6] git commit: [#5481] ticket:313 project members page
Date Fri, 12 Apr 2013 21:16:32 GMT
[#5481] ticket:313  project members page


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

Branch: refs/heads/cj/5481
Commit: cb93e7927290a45239b3a60b8ed5a02ef845d012
Parents: 9647941
Author: Yuriy Arhipov <yuriyarhipovua@yandex.ru>
Authored: Fri Apr 5 12:56:22 2013 +0400
Committer: Cory Johns <cjohns@slashdotmedia.com>
Committed: Fri Apr 12 17:16:16 2013 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/project.py |   19 +++++++++++++++++++
 Allura/allura/lib/macro.py           |    9 +++++++++
 Allura/allura/lib/plugin.py          |    2 +-
 Allura/allura/templates/members.html |   28 ++++++++++++++++++++++++++++
 Allura/allura/tests/test_globals.py  |    9 ++++++++-
 ForgeWiki/forgewiki/wiki_main.py     |    1 +
 6 files changed, 66 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/cb93e792/Allura/allura/controllers/project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/project.py b/Allura/allura/controllers/project.py
index 891e18f..f91c543 100644
--- a/Allura/allura/controllers/project.py
+++ b/Allura/allura/controllers/project.py
@@ -317,6 +317,25 @@ class ProjectController(object):
 
         return app.root, remainder
 
+    @expose('jinja:allura:templates/members.html')
+    @with_trailing_slash
+    def _members(self, **kw):
+        users = []
+        for user in c.project.users():
+            roles = []
+            for role in user.project_role().roles:
+                r = M.ProjectRole.query.get(_id=role)
+                if r.name not in roles:
+                    roles.append(r.name)
+            users.append(dict(
+                display_name = user.display_name,
+                username = user.username,
+                url = user.url(),
+                roles = roles,
+                email_addresses = user.email_addresses,
+                skills = user.get_skills()))
+        return dict(users=users)
+
     def _check_security(self):
         require_access(c.project, 'read')
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/cb93e792/Allura/allura/lib/macro.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/macro.py b/Allura/allura/lib/macro.py
index ff5a0d3..4615828 100644
--- a/Allura/allura/lib/macro.py
+++ b/Allura/allura/lib/macro.py
@@ -8,6 +8,7 @@ import traceback
 import pymongo
 from pylons import tmpl_context as c, app_globals as g
 from pylons import request
+from urlparse import urljoin
 
 from . import helpers as h
 from . import security
@@ -344,4 +345,12 @@ def project_admins():
                 url=user_role.user.url(),
                 name=user_role.user.display_name))
             for user_role in admin_role.users_with_role())
+    return u'<p>Project Admins:<br/>{}</p>'.format(output)
+
+template_members = string.Template('<a href="$url">Members</a><br/>')
+@macro()
+def members():
+    output = ''.join(
+            template_members.substitute(dict(
+                url=urljoin(c.project.url(),'_members'),)))
     return u'<p>{}</p>'.format(output)

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/cb93e792/Allura/allura/lib/plugin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/plugin.py b/Allura/allura/lib/plugin.py
index efc5d07..77207a2 100644
--- a/Allura/allura/lib/plugin.py
+++ b/Allura/allura/lib/plugin.py
@@ -521,7 +521,7 @@ class ProjectRegistrationProvider(object):
                     if tool == 'wiki':
                         from forgewiki import model as WM
                         text = tool_config.get('home_text',
-                            '[[project_admins]]\n[[download_button]]')
+                            '[[project_admins]]\n[[members]]\n[[download_button]]')
                         WM.Page.query.get(app_config_id=app.config._id).text = text
 
         if 'tool_order' in project_template:

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/cb93e792/Allura/allura/templates/members.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/members.html b/Allura/allura/templates/members.html
new file mode 100644
index 0000000..06d353a
--- /dev/null
+++ b/Allura/allura/templates/members.html
@@ -0,0 +1,28 @@
+{% set hide_left_bar = True %}
+{% extends g.theme.master %}
+{% block title %}Members{% endblock %}
+{% block header %}Members{% endblock %}
+{% block content %}
+<div class="grid-23">
+<div style="overflow:auto">
+<table>
+    <thead>
+    <tr>
+        <th >Developer</th>
+        <th>Username</th>
+        <th>Role/Position</th>
+        <th>Email</th>
+    </tr>
+    </thead>
+    {%for user in users%}
+    <tr>
+        <td >{{ user.display_name }}</td>
+        <td ><a href="{{ user.url }}">{{ user.username }}</a></td>
+        <td >{% for role in user.roles%} {{ role }}</br> {%endfor%}</td>
+        <td >{% for email in user.email_addresses %}{{email}}{%endfor%}</td>
+    </tr>
+    {%endfor%}
+</table>
+</div>
+</div>
+{% endblock %}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/cb93e792/Allura/allura/tests/test_globals.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_globals.py b/Allura/allura/tests/test_globals.py
index 7ad940e..4fa37cc 100644
--- a/Allura/allura/tests/test_globals.py
+++ b/Allura/allura/tests/test_globals.py
@@ -149,11 +149,17 @@ def test_macros():
     r = g.markdown_wiki.convert('[[neighborhood_blog_posts]]')
     assert 'test content' in r
 
+def test_macro_members():
+    user = M.User.by_username('test-admin')
+    user.display_name = u'Test Ådmin'
+    r = g.markdown_wiki.convert('[[members]]')
+    assert_equal(r, u'<div class="markdown_content"><p><a href="/p/test/_members">Members</a><br
/></p>\n</div>')
+
 def test_macro_project_admins():
     user = M.User.by_username('test-admin')
     user.display_name = u'Test Ådmin'
     r = g.markdown_wiki.convert('[[project_admins]]')
-    assert_equal(r, u'<div class="markdown_content"><p><a href="/u/test-admin/">Test
Ådmin</a><br /></p>\n</div>')
+    assert_equal(r, u'<div class="markdown_content"><p>Project Admins:<br
/><a href="/u/test-admin/">Test Ådmin</a><br /></p>\n</div>')
 
 def test_macro_project_admins_one_br():
     p_nbhd = M.Neighborhood.query.get(name='Projects')
@@ -161,6 +167,7 @@ def test_macro_project_admins_one_br():
     p_test.add_user(M.User.by_username('test-user'), ['Admin'])
     ThreadLocalORMSession.flush_all()
     r = g.markdown_wiki.convert('[[project_admins]]\n[[download_button]]')
+
     assert not '</a><br /><br /><a href=' in r, r
     assert '</a><br /><a href=' in r, r
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/cb93e792/ForgeWiki/forgewiki/wiki_main.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/wiki_main.py b/ForgeWiki/forgewiki/wiki_main.py
index 219fe00..ce253fb 100644
--- a/ForgeWiki/forgewiki/wiki_main.py
+++ b/ForgeWiki/forgewiki/wiki_main.py
@@ -247,6 +247,7 @@ This is the default page, edit it as you see fit. To add a new page simply
refer
 The wiki uses [Markdown](%s) syntax.
 
 [[project_admins]]
+[[members]]
 [[download_button]]
 """ % url
                 p.commit()


Mime
View raw message