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/06 09:28:54 UTC

[03/13] 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/a8e26c6a
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/a8e26c6a
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/a8e26c6a

Branch: refs/heads/hs/7919
Commit: a8e26c6ad91d61396c46e0b933e3ff8b7f41df6c
Parents: edcb115
Author: Heith Seewald <hs...@hsmb.local>
Authored: Tue Oct 6 03:02:55 2015 -0400
Committer: Heith Seewald <hs...@hsmb.local>
Committed: Tue Oct 6 03:02:55 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/a8e26c6a/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 dcda9be..4360ace 100644
--- a/Allura/allura/ext/admin/admin_main.py
+++ b/Allura/allura/ext/admin/admin_main.py
@@ -761,6 +761,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.