You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by he...@apache.org on 2015/10/15 21:01:06 UTC

[19/42] allura git commit: [#7919] Add rest endpoints for NavBar grouping and reordering

[#7919] Add rest endpoints for NavBar grouping and reordering


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

Branch: refs/heads/hs/7919
Commit: a38ab24b5b9651c831f745d7988b3c8e8ba2936a
Parents: 4328524
Author: Heith Seewald <hs...@hsmb.local>
Authored: Tue Oct 6 03:02:55 2015 -0400
Committer: Heith Seewald <hs...@hsmb.local>
Committed: Thu Oct 15 15:00:16 2015 -0400

----------------------------------------------------------------------
 Allura/allura/ext/admin/admin_main.py | 45 ++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/a38ab24b/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 7affa3c..0fbdaf2 100644
--- a/Allura/allura/ext/admin/admin_main.py
+++ b/Allura/allura/ext/admin/admin_main.py
@@ -762,6 +762,51 @@ class ProjectAdminRestController(BaseController):
 
     @expose('json:')
     @require_post()
+    def mount_order(self, subs=None, tools=None, **kw):
+        if kw:
+            for ordinal, mount_point in kw.iteritems():
+                try:
+                    c.project.app_config(mount_point).options.ordinal = int(ordinal)
+                except AttributeError as e:
+                    # Handle subproject
+                    print("Handle subproject", mount_point)
+                    p = M.Project.query.get(shortname="{}/{}".format(c.project.shortname, mount_point),
+                                            neighborhood_id=c.project.neighborhood_id)
+                    if p:
+                        p.ordinal = int(ordinal)
+        M.AuditLog.log('Updated NavBar mount order for {}'.format(c.project.name))
+        return {'status': 'ok'}
+
+
+    @expose('json:')
+    @require_post()
+    def configure_tool_grouping(self, grouping_threshold='1', **kw):
+        try:
+            grouping_threshold = int(grouping_threshold)
+            if grouping_threshold < 1:
+                raise ValueError('Invalid threshold')
+            c.project.set_tool_data(
+                'allura', grouping_threshold=grouping_threshold)
+        except ValueError:
+            return {
+                'status': 'error',
+                'msg': 'Invalid threshold'
+            }
+        M.AuditLog.log('Updated grouping threshold for {}'.format(c.project.name))
+        return {'status': 'ok'}
+
+    @expose('json:')
+    def tools(self, **kw):
+        """ List of installable tools
+
+        """
+        response.content_type = 'application/json'
+        tools_names = [t['name'] for t in AdminApp.installable_tools_for(c.project)]
+
+        return {'status': 'ok'}
+
+    @expose('json:')
+    @require_post()
     def export(self, tools=None, send_email=False, **kw):
         """
         Initiate a bulk export of the project data.