allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jetm...@apache.org
Subject [01/11] allura git commit: [#7832] ticket:731 Add rest api controllers for app admin
Date Mon, 23 Feb 2015 13:27:56 GMT
Repository: allura
Updated Branches:
  refs/heads/ib/7832 [created] 42c0cfcaa


[#7832] ticket:731 Add rest api controllers for app admin


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

Branch: refs/heads/ib/7832
Commit: 43000407f2c033daadb906ef3311c3f0b1b04a59
Parents: 746ee51
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Fri Feb 20 09:48:05 2015 +0000
Committer: Igor Bondarenko <jetmind2@gmail.com>
Committed: Mon Feb 23 09:45:13 2015 +0000

----------------------------------------------------------------------
 Allura/allura/app.py                  |  5 +++++
 Allura/allura/ext/admin/admin_main.py |  7 +++++++
 Allura/allura/lib/repository.py       | 20 ++++++++++++++++++++
 3 files changed, 32 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/43000407/Allura/allura/app.py
----------------------------------------------------------------------
diff --git a/Allura/allura/app.py b/Allura/allura/app.py
index b9fd6b7..4e1ed5d 100644
--- a/Allura/allura/app.py
+++ b/Allura/allura/app.py
@@ -211,6 +211,10 @@ class Application(object):
     :cvar Controller api_root: Serves API access at
         /rest/<neighborhood>/<project>/<app>/. Default is None - subclasses
         should override to expose API access to the Application.
+    :cvar Controller admin_api_root: Serves Admin API access at
+        /rest/<neighborhood>/<project>/admin/<app>/. Default is None -
+        subclasses should override to expose Admin API access to the
+        Application.
     :ivar Controller admin: Serves admin functions at
         /<neighborhood>/<project>/<admin>/<app>/. Default is a
         :class:`DefaultAdminController` instance.
@@ -227,6 +231,7 @@ class Application(object):
     script_name = None
     root = None  # root controller
     api_root = None
+    admin_api_root = None
     permissions = []
     permissions_desc = {
         'unmoderated_post': 'Post comments without moderation.',

http://git-wip-us.apache.org/repos/asf/allura/blob/43000407/Allura/allura/ext/admin/admin_main.py
----------------------------------------------------------------------
diff --git a/Allura/allura/ext/admin/admin_main.py b/Allura/allura/ext/admin/admin_main.py
index b812b0d..d5ae068 100644
--- a/Allura/allura/ext/admin/admin_main.py
+++ b/Allura/allura/ext/admin/admin_main.py
@@ -884,6 +884,13 @@ class ProjectAdminRestController(BaseController):
                     % (tool, mount_point, mount_label)
         }
 
+    @expose()
+    def _lookup(self, name, *remainder):
+        app = c.project.app_instance(name)
+        if app is None or app.admin_api_root is None:
+            raise exc.HTTPNotFound, name
+        return app.admin_api_root, remainder
+
 
 class PermissionsController(BaseController):
     def _check_security(self):

http://git-wip-us.apache.org/repos/asf/allura/blob/43000407/Allura/allura/lib/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/repository.py b/Allura/allura/lib/repository.py
index 9a4966f..d5d467b 100644
--- a/Allura/allura/lib/repository.py
+++ b/Allura/allura/lib/repository.py
@@ -28,6 +28,7 @@ from ming.utils import LazyProperty
 
 import allura.tasks
 from allura import version
+from allura.controllers.base import BaseController
 from allura.lib import helpers as h
 from allura import model as M
 from allura.lib import security
@@ -75,6 +76,7 @@ class RepositoryApp(Application):
     def __init__(self, project, config):
         Application.__init__(self, project, config)
         self.admin = RepoAdminController(self)
+        self.admin_api_root = RepoAdminRestController(self)
 
     def main_menu(self):
         '''Apps should provide their entries to be added to the main nav
@@ -274,3 +276,21 @@ class RepoAdminController(DefaultAdminController):
         else:
             flash("Invalid external checkout URL: %s" % c.form_errors['external_checkout_url'],
"error")
         redirect(c.project.url() + 'admin/tools')
+
+
+class RepoAdminRestController(BaseController):
+    def __init__(self, app):
+        self.app = app
+        self.webhooks = RestWebhooksLookup(app)
+
+
+class RestWebhooksLookup(BaseController):
+    def __init__(self, app):
+        self.app = app
+
+    @expose('json:')
+    def index(self, **kw):
+        webhooks = self.app._webhooks
+        if len(webhooks) == 0:
+            raise exc.HTTPNotFound()
+        return {'test': 'works'}


Mime
View raw message