allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [33/50] [abbrv] allura git commit: [#7919] new tools/subprojects to get proper last ordinal value
Date Thu, 17 Dec 2015 19:22:20 GMT
[#7919] new tools/subprojects to get proper last ordinal value


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

Branch: refs/heads/db/8034
Commit: 54bc381c41ee71f1e35b5a5066df6285c1f10f50
Parents: 478fc33
Author: Dave Brondsema <dave@brondsema.net>
Authored: Thu Dec 10 13:35:05 2015 -0500
Committer: Heith Seewald <heiths@gmail.com>
Committed: Wed Dec 16 13:55:39 2015 -0600

----------------------------------------------------------------------
 Allura/allura/ext/admin/admin_main.py           | 13 +++++-----
 .../admin/templates/project_install_tool.html   |  1 -
 Allura/allura/model/project.py                  | 27 +++++++++++++++++---
 3 files changed, 30 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/54bc381c/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 d9f87fa..f0bc151 100644
--- a/Allura/allura/ext/admin/admin_main.py
+++ b/Allura/allura/ext/admin/admin_main.py
@@ -343,7 +343,6 @@ class ProjectAdminController(BaseController):
                         'default_mount_label': 'SubProject',
                         'default_mount_point': 'subproject'
                     },
-                    total_mounts=999,  # FIXME
                     options=[],
             )
 
@@ -351,7 +350,6 @@ class ProjectAdminController(BaseController):
         return dict(
                 tool_name=tool_name,
                 tool=tool,
-                total_mounts=999,  # FIXME
                 options=tool.options_on_install(),
         )
 
@@ -700,7 +698,10 @@ class ProjectAdminController(BaseController):
                     meta=dict(mount_point=mount_point, name=new['mount_label']))
                 sp = c.project.new_subproject(mount_point)
                 sp.name = new['mount_label']
-                sp.ordinal = int(new['ordinal'])
+                if 'ordinal' in new:
+                    sp.ordinal = int(new['ordinal'])
+                else:
+                    sp.ordinal = c.project.last_ordinal_value() + 1
             else:
                 require_access(c.project, 'admin')
                 installable_tools = AdminApp.installable_tools_for(c.project)
@@ -722,7 +723,7 @@ class ProjectAdminController(BaseController):
                     ep_name,
                     mount_point,
                     mount_label=new['mount_label'],
-                    ordinal=new['ordinal'],
+                    ordinal=int(new['ordinal']) if 'ordinal' in new else None,
                     **config_on_install)
         g.post_event('project_updated')
 
@@ -763,9 +764,10 @@ class ProjectAdminController(BaseController):
             'status': c.project.bulk_export_status()
         }
 
+
 class ProjectAdminRestController(BaseController):
     """
-    Exposes RESTful APi for project admin actions.
+    Exposes RESTful API for project admin actions.
     """
 
     def _check_security(self):
@@ -788,7 +790,6 @@ class ProjectAdminRestController(BaseController):
         M.AuditLog.log('Updated tool order')
         return {'status': 'ok'}
 
-
     @expose('json:')
     @require_post()
     def configure_tool_grouping(self, grouping_threshold='1', **kw):

http://git-wip-us.apache.org/repos/asf/allura/blob/54bc381c/Allura/allura/ext/admin/templates/project_install_tool.html
----------------------------------------------------------------------
diff --git a/Allura/allura/ext/admin/templates/project_install_tool.html b/Allura/allura/ext/admin/templates/project_install_tool.html
index 0e6d98d..82f6f65 100644
--- a/Allura/allura/ext/admin/templates/project_install_tool.html
+++ b/Allura/allura/ext/admin/templates/project_install_tool.html
@@ -14,7 +14,6 @@
 {% endif %}
 
 <form method="post" action="{{ full_url }}admin/update_mounts" id="install_form">
-    <input type="hidden" name="new.ordinal" value="{{ total_mounts }}"/>
     <input type="hidden" name="new.ep_name" class="new_ep_name" value="{{ tool_name }}">
     <label class="grid-13" for="new.mount_label">Label</label>
     <div class="grid-13"><input type="text" name="new.mount_label" class="new_mount_label"

http://git-wip-us.apache.org/repos/asf/allura/blob/54bc381c/Allura/allura/model/project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/project.py b/Allura/allura/model/project.py
index 158904a..6a2007d 100644
--- a/Allura/allura/model/project.py
+++ b/Allura/allura/model/project.py
@@ -776,12 +776,29 @@ class Project(SearchIndexable, MappedClass, ActivityNode, ActivityObject):
         except fe.Invalid as e:
             raise exceptions.ToolError(u'{}: {}'.format(opt.name, str(e)))
 
+    def last_ordinal_value(self):
+        last_menu_item = self.ordered_mounts(include_hidden=True)[-1]
+        if 'ac' in last_menu_item:
+            ordinal = last_menu_item['ac'].options.ordinal
+        else:
+            ordinal = last_menu_item['sub'].ordinal
+        return ordinal
+
     def install_app(self, ep_name, mount_point=None, mount_label=None, ordinal=None, **override_options):
+        '''
+        Install an app
+
+        :param str ep_name: Entry Point name, e.g. "wiki"
+        :param str mount_point: URL path, e.g. "docs"
+        :param str mount_label: Display name
+        :param int ordinal: location of tool, relative to others; None will go to the end.
+        :param override_options:
+        :return:
+        '''
         App = g.entry_points['tool'][ep_name]
         mount_point = self._mount_point_for_install(App, mount_point)
         if ordinal is None:
-            ordinal = int(self.ordered_mounts(include_hidden=True)
-                          [-1]['ordinal']) + 1
+            ordinal = self.last_ordinal_value() + 1
         options = App.default_options()
         options['mount_point'] = mount_point
         options['mount_label'] = mount_label or App.default_mount_label or mount_point
@@ -843,8 +860,10 @@ class Project(SearchIndexable, MappedClass, ActivityNode, ActivityObject):
         return provider.register_subproject(self, name, user or c.user, install_apps, project_name=project_name)
 
     def ordered_mounts(self, include_hidden=False):
-        '''Returns an array of a projects mounts (tools and sub-projects) in
-        toolbar order.'''
+        '''
+        Returns an array of a projects mounts (tools and sub-projects) in toolbar order.
+        Note that the top-level 'ordinal' field may be offset from the stored ordinal value,
due to anchored tools
+        '''
         result = []
         anchored_tools = self.neighborhood.get_anchored_tools()
         i = len(anchored_tools)


Mime
View raw message