allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [1/5] git commit: [#7014] Added trove category controller to site admin via new extension point
Date Mon, 24 Feb 2014 15:16:56 GMT
Repository: incubator-allura
Updated Branches:
  refs/heads/master fc1c466ab -> ab5f24b8d


[#7014] Added trove category controller to site admin via new extension point

Signed-off-by: Cory Johns <cjohns@slashdotmedia.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/ab5f24b8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/ab5f24b8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/ab5f24b8

Branch: refs/heads/master
Commit: ab5f24b8dc85855fd5565d524338eecf693c47e6
Parents: 2fdefbf
Author: Cory Johns <cjohns@slashdotmedia.com>
Authored: Thu Feb 20 23:12:22 2014 +0000
Committer: Cory Johns <cjohns@slashdotmedia.com>
Committed: Mon Feb 24 15:15:41 2014 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/trovecategories.py      | 18 ++++++++++++++----
 Allura/allura/templates/user_skills.html          |  2 +-
 .../allura/tests/functional/test_trovecategory.py |  2 +-
 Allura/setup.py                                   |  1 +
 4 files changed, 17 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ab5f24b8/Allura/allura/controllers/trovecategories.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/trovecategories.py b/Allura/allura/controllers/trovecategories.py
index ceba651..959713d 100644
--- a/Allura/allura/controllers/trovecategories.py
+++ b/Allura/allura/controllers/trovecategories.py
@@ -19,6 +19,7 @@ from tg import expose, flash, redirect, validate, config
 from pylons import tmpl_context as c
 from string import digits, lowercase
 from webob.exc import HTTPForbidden
+from pylons import app_globals as g
 
 from allura import model as M
 from allura.controllers import BaseController
@@ -26,6 +27,8 @@ from allura.lib import helpers as h
 from allura.lib.decorators import require_post
 from allura.lib.security import require_authenticated, require_access
 from allura.lib.widgets import forms
+from allura.lib.plugin import SiteAdminExtension
+from allura.app import SitemapEntry
 
 
 class F(object):
@@ -41,16 +44,15 @@ class TroveCategoryController(BaseController):
         return TroveCategoryController(category=cat), remainder
 
     def _check_security(self):
-        enable_editing = config.get('trovecategories.enableediting', 'false')
-        if enable_editing == 'false':
-            raise HTTPForbidden()
-
         require_authenticated()
 
+        enable_editing = config.get('trovecategories.enableediting', 'false')
         if enable_editing == 'admin':
             with h.push_context(config.get('site_admin_project', 'allura'),
                                 neighborhood=config.get('site_admin_project_nbhd', 'Projects')):
                 require_access(c.project, 'admin')
+        elif enable_editing != 'true':
+            raise HTTPForbidden()
 
     def __init__(self, category=None):
         self.category = category
@@ -212,3 +214,11 @@ class TroveCategoryController(BaseController):
 
         flash('Category removed.')
         redirect(redirecturl)
+
+
+class TroveCategorySiteAdminExtension(SiteAdminExtension):
+    def update_sidebar_menu(self, links):
+        enable_editing = config.get('trovecategories.enableediting', 'false')
+        if enable_editing in ('admin', 'true'):
+            links.append(SitemapEntry('Troves', '/categories',
+                ui_icon=g.icons['admin']))

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ab5f24b8/Allura/allura/templates/user_skills.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/user_skills.html b/Allura/allura/templates/user_skills.html
index 0838a97..cc5d02b 100644
--- a/Allura/allura/templates/user_skills.html
+++ b/Allura/allura/templates/user_skills.html
@@ -99,7 +99,7 @@
     <h3>Other possible actions</h3>
     <div class="grid-20" style="margin-bottom:10px;"/>
       <ul>
-        {%if tg.config.get('trovecategories.enableediting', 'false')!='false'%}
+        {% if tg.config.get('trovecategories.enableediting', 'false') == 'true' %}
           {% if selected_skill %}
             <li>
               <a href="/categories/{{selected_skill.shortname}}">

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ab5f24b8/Allura/allura/tests/functional/test_trovecategory.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_trovecategory.py b/Allura/allura/tests/functional/test_trovecategory.py
index 2f0bd54..c9a8cc3 100644
--- a/Allura/allura/tests/functional/test_trovecategory.py
+++ b/Allura/allura/tests/functional/test_trovecategory.py
@@ -38,7 +38,7 @@ class TestTroveCategory(TestController):
         deleted_category_id = post_event.call_args[0][1]
         assert_true(isinstance(deleted_category_id, ObjectId))
         assert_equals(deleted_category_id, category_id)
-        assert_equals(post_event.call_args[0][0], 'trove_category_deleted')        
+        assert_equals(post_event.call_args[0][0], 'trove_category_deleted')
 
     def test_enableediting_setting(self):
         def check_access(username=None, status=None):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ab5f24b8/Allura/setup.py
----------------------------------------------------------------------
diff --git a/Allura/setup.py b/Allura/setup.py
index 7d2d924..1d04828 100644
--- a/Allura/setup.py
+++ b/Allura/setup.py
@@ -125,6 +125,7 @@ setup(
 
     [allura.site_admin]
     stats = allura.controllers.site_admin:StatsSiteAdminExtension
+    troves = allura.controllers.trovecategories:TroveCategorySiteAdminExtension
 
     [allura.user_profile.sections]
     personal-data = allura.ext.user_profile.user_main:PersonalDataSection


Mime
View raw message