allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [22/27] git commit: [#5517] Add permission descriptions
Date Tue, 23 Jul 2013 22:36:38 GMT
[#5517] Add permission descriptions

Signed-off-by: Tim Van Steenburgh <tvansteenburgh@gmail.com>


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

Branch: refs/heads/cj/6456
Commit: 2dcec81c7d4e861fc47c348f25333ec3b547e510
Parents: 3e8ba0f
Author: Tim Van Steenburgh <tvansteenburgh@gmail.com>
Authored: Thu Jul 18 15:44:39 2013 +0000
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Tue Jul 23 21:07:31 2013 +0000

----------------------------------------------------------------------
 Allura/allura/app.py                            | 24 ++++++++++++++++++++
 .../templates/admin_widgets/card_field.html     |  5 +++-
 Allura/allura/lib/repository.py                 |  6 +++++
 .../allura/templates/app_admin_permissions.html |  1 +
 Allura/allura/tests/unit/test_app.py            | 12 ++++++++++
 ForgeBlog/forgeblog/main.py                     |  5 ++++
 ForgeChat/forgechat/main.py                     |  4 ++++
 ForgeDiscussion/forgediscussion/forum_main.py   |  5 ++++
 ForgeLink/forgelink/link_main.py                |  3 +++
 ForgeSVN/forgesvn/svn_main.py                   |  4 ++++
 ForgeShortUrl/forgeshorturl/main.py             |  6 +++++
 ForgeTracker/forgetracker/tracker_main.py       | 11 +++++++++
 ForgeUserStats/forgeuserstats/main.py           |  4 ++++
 ForgeWiki/forgewiki/wiki_main.py                |  7 ++++++
 14 files changed, 96 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/2dcec81c/Allura/allura/app.py
----------------------------------------------------------------------
diff --git a/Allura/allura/app.py b/Allura/allura/app.py
index 4599009..2b839fc 100644
--- a/Allura/allura/app.py
+++ b/Allura/allura/app.py
@@ -208,6 +208,13 @@ class Application(object):
     root = None  # root controller
     api_root = None
     permissions = []
+    permissions_desc = {
+        'unmoderated_post': 'Post comments without moderation.',
+        'post': 'Post comments, subject to moderation.',
+        'moderate': 'Moderate comments.',
+        'configure': 'Set label and options. Requires admin permission.',
+        'admin': 'Set permissions.',
+    }
     installable = True
     searchable = False
     DiscussionClass = model.Discussion
@@ -265,6 +272,23 @@ class Application(object):
         """
         return self.config.acl
 
+    @classmethod
+    def describe_permission(cls, permission):
+        """Return help text describing what features ``permission`` controls.
+
+        Subclasses should define :attr:`permissions_desc`,
+        a ``{permission: description}`` mapping.
+
+        Returns empty string if there is no description for ``permission``.
+
+        """
+        if not hasattr(cls, '_permissions_desc'):
+            d = {}
+            for t in reversed(cls.__mro__):
+                d = dict(d, **getattr(t, 'permissions_desc', {}))
+            cls._permissions_desc = d
+        return cls._permissions_desc.get(permission, '')
+
     def parent_security_context(self):
         """Return the parent of this object.
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/2dcec81c/Allura/allura/ext/admin/templates/admin_widgets/card_field.html
----------------------------------------------------------------------
diff --git a/Allura/allura/ext/admin/templates/admin_widgets/card_field.html b/Allura/allura/ext/admin/templates/admin_widgets/card_field.html
index fe03142..770910e 100644
--- a/Allura/allura/ext/admin/templates/admin_widgets/card_field.html
+++ b/Allura/allura/ext/admin/templates/admin_widgets/card_field.html
@@ -32,6 +32,9 @@
             data-icon="{{g.icons[icon_name].char}}"
             class="ico x48 {{g.icons[icon_name].css}}"></b>
       </p>
+      {% if desc %}
+      <p>{{ desc }}</p>
+      {% endif %}
       <ul class="subroles">
         {% for role in roles %}
           {% if role.name %}
@@ -44,7 +47,7 @@
     <li>
         <a href="#" class="deleter">
           {{ widget.item_display(item) }}
-          <input type="hidden" name="card-{{index}}.value" 
+          <input type="hidden" name="card-{{index}}.value"
                  {{ widget.j2_attrs(dict(value=widget.item_id(item))) }} />
           <small data-icon="{{g.icons['perm_delete'].char}}"
                  class="ico-r {{g.icons['perm_delete'].css}}"

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/2dcec81c/Allura/allura/lib/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/repository.py b/Allura/allura/lib/repository.py
index 95a3d54..a8665a8 100644
--- a/Allura/allura/lib/repository.py
+++ b/Allura/allura/lib/repository.py
@@ -46,6 +46,12 @@ class RepositoryApp(Application):
         'read', 'write', 'create',
         'unmoderated_post', 'post', 'moderate', 'admin',
         'configure']
+    permissions_desc = {
+        'read': 'Repo read access.',
+        'write': 'Repo push access.',
+        'create': 'Not used.',
+        'admin': 'Set permissions, default branch, and viewable files.',
+    }
     config_options = Application.config_options + [
         ConfigOption('cloned_from_project_id', ObjectId, None),
         ConfigOption('cloned_from_repo_id', ObjectId, None),

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/2dcec81c/Allura/allura/templates/app_admin_permissions.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/app_admin_permissions.html b/Allura/allura/templates/app_admin_permissions.html
index 039a898..088588a 100644
--- a/Allura/allura/templates/app_admin_permissions.html
+++ b/Allura/allura/templates/app_admin_permissions.html
@@ -38,6 +38,7 @@
             index=i1,
             id=name,
             name=name,
+            desc=app.describe_permission(name),
             items=h.make_roles(ids)
         )}}
         {% endfor %}

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/2dcec81c/Allura/allura/tests/unit/test_app.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/unit/test_app.py b/Allura/allura/tests/unit/test_app.py
index 01f4be1..903737c 100644
--- a/Allura/allura/tests/unit/test_app.py
+++ b/Allura/allura/tests/unit/test_app.py
@@ -34,6 +34,18 @@ class TestApplication(TestCase):
         app.relaxed_mount_points = True
         self.assertIsNotNone(app.validate_mount_point(mount_point))
 
+    def test_describe_permission(self):
+        class DummyApp(Application):
+            permissions_desc = {
+                'foo': 'bar',
+                'post': 'overridden',
+            }
+        f = DummyApp.describe_permission
+        self.assertEqual(f('foo'), 'bar')
+        self.assertEqual(f('post'), 'overridden')
+        self.assertEqual(f('admin'), 'Set permissions.')
+        self.assertEqual(f('does_not_exist'), '')
+
 
 class TestInstall(WithDatabase):
     patches = [fake_app_patch]

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/2dcec81c/ForgeBlog/forgeblog/main.py
----------------------------------------------------------------------
diff --git a/ForgeBlog/forgeblog/main.py b/ForgeBlog/forgeblog/main.py
index 0b9ff70..5f54a38 100644
--- a/ForgeBlog/forgeblog/main.py
+++ b/ForgeBlog/forgeblog/main.py
@@ -82,6 +82,11 @@ class ForgeBlogApp(Application):
     default_mount_point='blog'
     permissions = ['configure', 'read', 'write',
                     'unmoderated_post', 'post', 'moderate', 'admin']
+    permissions_desc = {
+        'read': 'View blog entries.',
+        'write': 'Create new blog entry.',
+        'admin': 'Set permissions. Enable/disable commenting.',
+    }
     ordinal=14
     installable=True
     config_options = Application.config_options

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/2dcec81c/ForgeChat/forgechat/main.py
----------------------------------------------------------------------
diff --git a/ForgeChat/forgechat/main.py b/ForgeChat/forgechat/main.py
index d7a9860..202e01d 100644
--- a/ForgeChat/forgechat/main.py
+++ b/ForgeChat/forgechat/main.py
@@ -52,6 +52,10 @@ class ForgeChatApp(Application):
     ordinal=13
     installable = True
     permissions = ['configure', 'read' ]
+    permissions_desc = {
+        'configure': 'Set monitored IRC channel. Requires admin permission.',
+        'read': 'View chat logs.',
+    }
     config_options = Application.config_options + [
         ConfigOption('channel', str, ''),
         ]

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/2dcec81c/ForgeDiscussion/forgediscussion/forum_main.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/forum_main.py b/ForgeDiscussion/forgediscussion/forum_main.py
index 75b0104..730f007 100644
--- a/ForgeDiscussion/forgediscussion/forum_main.py
+++ b/ForgeDiscussion/forgediscussion/forum_main.py
@@ -55,6 +55,11 @@ class ForgeDiscussionApp(Application):
     __version__ = version.__version__
     #installable=False
     permissions = ['configure', 'read', 'unmoderated_post', 'post', 'moderate', 'admin']
+    permissions_desc = {
+        'configure': 'Create new forums.',
+        'read': 'View posts.',
+        'admin': 'Set permissions. Edit forum properties.',
+    }
     config_options = Application.config_options + [
         ConfigOption('PostingPolicy',
                      schema.OneOf('ApproveOnceModerated', 'ModerateAll'), 'ApproveOnceModerated')

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/2dcec81c/ForgeLink/forgelink/link_main.py
----------------------------------------------------------------------
diff --git a/ForgeLink/forgelink/link_main.py b/ForgeLink/forgelink/link_main.py
index 370e6cc..be8c918 100644
--- a/ForgeLink/forgelink/link_main.py
+++ b/ForgeLink/forgelink/link_main.py
@@ -42,6 +42,9 @@ class ForgeLinkApp(Application):
     '''This is the Link app for PyForge'''
     __version__ = version.__version__
     permissions = [ 'configure', 'read' ]
+    permissions_desc = {
+        'read': 'View link.',
+    }
     config_options = Application.config_options + [
         ConfigOption('url', str, None)
     ]

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/2dcec81c/ForgeSVN/forgesvn/svn_main.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/svn_main.py b/ForgeSVN/forgesvn/svn_main.py
index de1e0df..03b1b7f 100644
--- a/ForgeSVN/forgesvn/svn_main.py
+++ b/ForgeSVN/forgesvn/svn_main.py
@@ -51,6 +51,10 @@ class ForgeSVNApp(RepositoryApp):
     config_options = RepositoryApp.config_options + [
         ConfigOption('checkout_url', str, '')
         ]
+    permissions_desc = dict(RepositoryApp.permissions_desc, **{
+        'write': 'Repo commit access.',
+        'admin': 'Set permissions, checkout url, and viewable files. Import a remote repo.',
+    })
     tool_label='SVN'
     tool_description="""
         Enterprise-class centralized version control for the masses.

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/2dcec81c/ForgeShortUrl/forgeshorturl/main.py
----------------------------------------------------------------------
diff --git a/ForgeShortUrl/forgeshorturl/main.py b/ForgeShortUrl/forgeshorturl/main.py
index c8e16c0..f9217df 100644
--- a/ForgeShortUrl/forgeshorturl/main.py
+++ b/ForgeShortUrl/forgeshorturl/main.py
@@ -52,6 +52,12 @@ class W:
 
 class ForgeShortUrlApp(Application):
     permissions = ['read', 'create', 'update', 'view_private']
+    permissions_desc = {
+        'read': 'View public short urls.',
+        'create': 'Create new short url. Requires admin permission.',
+        'update': 'Edit/remove existing short url. Requires admin permission.',
+        'view_private': 'View private short urls.',
+    }
     searchable = True
     tool_label = 'URL shortener'
     default_mount_label = 'URL shortener'

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/2dcec81c/ForgeTracker/forgetracker/tracker_main.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tracker_main.py b/ForgeTracker/forgetracker/tracker_main.py
index b6af2ee..a1363dc 100644
--- a/ForgeTracker/forgetracker/tracker_main.py
+++ b/ForgeTracker/forgetracker/tracker_main.py
@@ -188,6 +188,17 @@ class ForgeTrackerApp(Application):
     __version__ = version.__version__
     permissions = ['configure', 'read', 'update', 'create', 'save_searches',
                     'unmoderated_post', 'post', 'moderate', 'admin', 'delete']
+    permissions_desc = {
+        'configure': 'Edit milestones.',
+        'read': 'View tickets.',
+        'update': 'Edit tickets.',
+        'create': 'Create tickets.',
+        'save_searches': 'Not used.',
+        'admin': 'Set permissions. Configure options, saved searches, custom fields, '
+            'and default list view columns. Move tickets to or from this '
+            'tracker. Import tickets.',
+        'delete': 'Delete and undelete tickets. View deleted tickets.',
+    }
     config_options = Application.config_options + [
         ConfigOption('EnableVoting', bool, False),
         ConfigOption('TicketMonitoringEmail', str, ''),

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/2dcec81c/ForgeUserStats/forgeuserstats/main.py
----------------------------------------------------------------------
diff --git a/ForgeUserStats/forgeuserstats/main.py b/ForgeUserStats/forgeuserstats/main.py
index 1951cee..4d41676 100644
--- a/ForgeUserStats/forgeuserstats/main.py
+++ b/ForgeUserStats/forgeuserstats/main.py
@@ -93,6 +93,10 @@ class ForgeUserStatsApp(Application):
     default_mount_point='stats'
     permissions = ['configure', 'read', 'write',
                     'unmoderated_post', 'post', 'moderate', 'admin']
+    permissions_desc = {
+        'read': 'View user stats.',
+        'admin': 'Toggle stats visibility.',
+    }
     ordinal=15
     installable=False
     config_options = Application.config_options

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/2dcec81c/ForgeWiki/forgewiki/wiki_main.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/wiki_main.py b/ForgeWiki/forgewiki/wiki_main.py
index 57e2bff..064a9cd 100644
--- a/ForgeWiki/forgewiki/wiki_main.py
+++ b/ForgeWiki/forgewiki/wiki_main.py
@@ -81,6 +81,13 @@ class ForgeWikiApp(Application):
     __version__ = version.__version__
     permissions = [ 'configure', 'read', 'create', 'edit', 'delete',
                     'unmoderated_post', 'post', 'moderate', 'admin']
+    permissions_desc = {
+        'read': 'View wiki pages.',
+        'create': 'Create wiki pages.',
+        'edit': 'Edit wiki pages.',
+        'delete': 'Delete wiki pages.',
+        'admin': 'Set permissions. Configure options. Set wiki home page.',
+    }
     searchable=True
     tool_label='Wiki'
     tool_description="""


Mime
View raw message