You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2015/08/17 21:38:09 UTC

[01/14] allura git commit: [#7922] Add "admin" section to the left sidebar

Repository: allura
Updated Branches:
  refs/heads/master b6b9e46cf -> 7c5a5de53


[#7922] Add "admin" section to the left sidebar


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

Branch: refs/heads/master
Commit: 46a4f68e4befc6ee4ed7df83fdf742b2817927ec
Parents: b6b9e46
Author: Igor Bondarenko <je...@gmail.com>
Authored: Wed Jul 29 19:25:49 2015 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon Aug 17 17:54:11 2015 +0000

----------------------------------------------------------------------
 Allura/allura/app.py                            | 22 +++++++++
 Allura/allura/ext/admin/admin_main.py           |  5 ++-
 .../ext/admin/templates/project_tools.html      | 44 ++++--------------
 Allura/allura/lib/widgets/admin_widgets.py      | 47 ++++++++++++++++++++
 .../lib/widgets/resources/js/admin_modal.js     | 34 ++++++++++++++
 .../resources/js/admin_tool_delete_modal.js     | 40 +++++++++++++++++
 Allura/allura/public/nf/js/project_tools.js     | 39 ----------------
 .../templates/jinja_master/sidebar_menu.html    | 11 +++++
 .../widgets/admin_tool_delete_modal.html        | 34 ++++++++++++++
 9 files changed, 199 insertions(+), 77 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/46a4f68e/Allura/allura/app.py
----------------------------------------------------------------------
diff --git a/Allura/allura/app.py b/Allura/allura/app.py
index 1d02ffa..5d76459 100644
--- a/Allura/allura/app.py
+++ b/Allura/allura/app.py
@@ -44,6 +44,7 @@ from allura import model
 from allura.controllers import BaseController
 from allura.lib.decorators import require_post, memoize
 from allura.lib.utils import permanent_redirect, ConfigProxy
+from allura.lib.widgets import admin_widgets
 from allura import model as M
 
 log = logging.getLogger(__name__)
@@ -291,6 +292,14 @@ class Application(object):
         self.admin = DefaultAdminController(self)
 
     @LazyProperty
+    def admin_modal(self):
+        return admin_widgets.AdminModal()
+
+    @LazyProperty
+    def admin_tool_delete_modal(self):
+        return admin_widgets.AdminToolDeleteModal()
+
+    @LazyProperty
     def sitemap(self):
         """Return a list of :class:`SitemapEntries <allura.app.SitemapEntry>`
         describing the page hierarchy provided by this Application.
@@ -616,6 +625,19 @@ class Application(object):
             links.append(SitemapEntry('Webhooks', admin_url + 'webhooks'))
         return links
 
+    @LazyProperty
+    def admin_menu_delete_button(self):
+        anchored_tools = self.project.neighborhood.get_anchored_tools()
+        anchored = self.tool_label.lower() in anchored_tools.keys()
+        if self.uninstallable and not anchored:
+            return SitemapEntry(
+                label='Delete',
+                url='#',
+                className='admin_tool_delete_modal',
+                extra_html_attrs={
+                    'data-mount-point': self.config.options.mount_point,
+                })
+
     def handle_message(self, topic, message):
         """Handle incoming email msgs addressed to this tool.
         Default is a no-op.

http://git-wip-us.apache.org/repos/asf/allura/blob/46a4f68e/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 ec61edb..dcda9be 100644
--- a/Allura/allura/ext/admin/admin_main.py
+++ b/Allura/allura/ext/admin/admin_main.py
@@ -44,6 +44,7 @@ from allura.controllers import BaseController
 from allura.lib.decorators import require_post
 from allura.tasks import export_tasks
 from allura.lib.widgets.project_list import ProjectScreenshots
+from allura.lib.widgets import admin_widgets
 
 from . import widgets as aw
 
@@ -54,8 +55,8 @@ log = logging.getLogger(__name__)
 class W:
     markdown_editor = ffw.MarkdownEdit()
     label_edit = ffw.LabelEdit()
-    mount_delete = ffw.Lightbox(name='mount_delete', trigger='a.mount_delete')
-    admin_modal = ffw.Lightbox(name='admin_modal', trigger='a.admin_modal')
+    admin_modal = admin_widgets.AdminModal()
+    mount_delete = admin_widgets.AdminToolDeleteModal()
     install_modal = ffw.Lightbox(
         name='install_modal', trigger='a.install_trig')
     explain_export_modal = ffw.Lightbox(

http://git-wip-us.apache.org/repos/asf/allura/blob/46a4f68e/Allura/allura/ext/admin/templates/project_tools.html
----------------------------------------------------------------------
diff --git a/Allura/allura/ext/admin/templates/project_tools.html b/Allura/allura/ext/admin/templates/project_tools.html
index 38705ed..c9eab4a 100644
--- a/Allura/allura/ext/admin/templates/project_tools.html
+++ b/Allura/allura/ext/admin/templates/project_tools.html
@@ -17,6 +17,7 @@
        under the License.
 -#}
 {% extends g.theme.master %}
+{% from 'allura:templates/jinja_master/sidebar_menu.html' import sidebar_item with context %}
 
 {% do g.register_forge_css('css/forge/deck.css') %}
 {% do g.register_forge_js('js/project_tools.js', location='body_js_tail') %}
@@ -87,24 +88,9 @@
                         <img src="{{ g.theme.app_icon_url(app, 48) }}" alt="">
                     </li>
                     {% for link in links %}
-                    <li>
-                        <a href="{{ link.url }}" class="{{ link.className }}">{{ link.label }}</a>
-                    </li>
+                      {{sidebar_item(link)}}
                     {% endfor %}
-                    {% if app.uninstallable and not (app.tool_label.lower() in app.project.neighborhood.get_anchored_tools().keys()) %}
-                    <li>
-                      <form method="post" action="update_mounts" id="mounts_edit_2-{{loop.index0}}">
-                        <input type="hidden" class="mount_point"
-                               name="tool-{{loop.index0}}.mount_point"
-                               value="{{mount['ac'].options.mount_point}}"/>
-                        <input name="tool-{{loop.index0}}.delete" type="hidden" value="Delete"/>
-                        {% if mount['ac'].load().uninstallable %}
-                          <a href="#" class="mount_delete" data-mount-point="{{ mount['ac'].options.mount_point }}">Delete</a>
-                        {% endif %}
-                        {{lib.csrf_token()}}
-                      </form>
-                    </li>
-                    {% endif %}
+                    {{sidebar_item(app.admin_menu_delete_button)}}
                 </ul>
                 {% if not app.uninstallable %}
                   <input type="hidden" class="mount_point" value="{{mount['ac'].options.mount_point}}"/>
@@ -119,14 +105,9 @@
                         <img src="{{ g.theme.app_icon_url('subproject', 48) }}" alt="">
                     </li>
                     <li>
-                      <form method="post" action="update_mounts" id="mounts_edit_2-{{loop.index0}}">
-                          <input type="hidden" class="shortname"
-                                 name="subproject-{{loop.index0}}.shortname"
-                                 value="{{mount['sub'].shortname}}"/>
-                          <input name="subproject-{{loop.index0}}.delete" type="hidden" value="Delete"/>
-                          <a href="#" class="mount_delete" data-mount-point="{{ mount['sub'].shortname }}">Delete</a>
-                          {{lib.csrf_token()}}
-                      </form>
+                      <a href="#" data-mount-point="{{ mount['sub'].shortname }}" class="admin_tool_delete_modal">
+                        <span>Delete</span>
+                      </a>
                     </li>
                 </ul>
             </div>
@@ -137,17 +118,8 @@
 <div style="clear:both">
   {{c.page_list.display(page=page, limit=limit, count=total_mounts)}}
 </div>
-<form id="mount_delete_form" style="display:none">
-  <div class="grid-13 warning_msg">Warning: This will destroy all data in this tool and is irreversible!</div>
-  <div class="grid-13">&nbsp;</div>
-  <hr>
-  <div class="grid-13">&nbsp;</div>
-  <div class="grid-13">
-    <input type="button" value="Delete" class="continue_delete"> <input type="button" value="Cancel" class="cancel_delete close">
-  </div>
-</form>
-{{c.admin_modal.display(content='<h1 id="popup_title"></h1><div id="popup_contents"></div>')}}
-{{c.mount_delete.display(content='<h1>Confirm Delete</h1>')}}
+{{c.admin_modal.display()}}
+{{c.mount_delete.display()}}
 <div><!--dummy-->
 
 <h3 style="clear:left">Grouping</h3>

http://git-wip-us.apache.org/repos/asf/allura/blob/46a4f68e/Allura/allura/lib/widgets/admin_widgets.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/admin_widgets.py b/Allura/allura/lib/widgets/admin_widgets.py
new file mode 100644
index 0000000..249962e
--- /dev/null
+++ b/Allura/allura/lib/widgets/admin_widgets.py
@@ -0,0 +1,47 @@
+#       Licensed to the Apache Software Foundation (ASF) under one
+#       or more contributor license agreements.  See the NOTICE file
+#       distributed with this work for additional information
+#       regarding copyright ownership.  The ASF licenses this file
+#       to you under the Apache License, Version 2.0 (the
+#       "License"); you may not use this file except in compliance
+#       with the License.  You may obtain a copy of the License at
+#
+#         http://www.apache.org/licenses/LICENSE-2.0
+#
+#       Unless required by applicable law or agreed to in writing,
+#       software distributed under the License is distributed on an
+#       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+#       KIND, either express or implied.  See the License for the
+#       specific language governing permissions and limitations
+#       under the License.
+
+import ew.jinja2_ew as ew
+
+from allura.lib.widgets import form_fields as ffw
+
+
+class AdminModal(ffw.Lightbox):
+    defaults = dict(
+        ffw.Lightbox.defaults,
+        name='admin_modal',
+        trigger='a.admin_modal',
+        content='<h1 id="admin_modal_title"></h1>'
+                '<div id="admin_modal_contents"></div>')
+
+    def resources(self):
+        for r in super(AdminModal, self).resources():
+            yield r
+        yield ew.JSLink('js/admin_modal.js')
+
+
+class AdminToolDeleteModal(ffw.Lightbox):
+    defaults = dict(
+        ffw.Lightbox.defaults,
+        name='admin_tool_delete_modal',
+        trigger='a.admin_tool_delete_modal',
+        content_template='allura:templates/widgets/admin_tool_delete_modal.html')
+
+    def resources(self):
+        for r in super(AdminToolDeleteModal, self).resources():
+            yield r
+        yield ew.JSLink('js/admin_tool_delete_modal.js')

http://git-wip-us.apache.org/repos/asf/allura/blob/46a4f68e/Allura/allura/lib/widgets/resources/js/admin_modal.js
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/resources/js/admin_modal.js b/Allura/allura/lib/widgets/resources/js/admin_modal.js
new file mode 100644
index 0000000..41a5264
--- /dev/null
+++ b/Allura/allura/lib/widgets/resources/js/admin_modal.js
@@ -0,0 +1,34 @@
+/*
+       Licensed to the Apache Software Foundation (ASF) under one
+       or more contributor license agreements.  See the NOTICE file
+       distributed with this work for additional information
+       regarding copyright ownership.  The ASF licenses this file
+       to you under the Apache License, Version 2.0 (the
+       "License"); you may not use this file except in compliance
+       with the License.  You may obtain a copy of the License at
+
+         http://www.apache.org/licenses/LICENSE-2.0
+
+       Unless required by applicable law or agreed to in writing,
+       software distributed under the License is distributed on an
+       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+       KIND, either express or implied.  See the License for the
+       specific language governing permissions and limitations
+       under the License.
+*/
+$(function() {
+    var cval = $.cookie('_session_id');
+    var csrf_input = $('<input name="_session_id" type="hidden" value="'+cval+'">');
+    var $popup_title = $('#admin_modal_title');
+    var $popup_contents = $('#admin_modal_contents');
+    $('a.admin_modal').click(function () {
+        var link = this;
+        $popup_title.html('');
+        $popup_contents.html('Loading...');
+        $.get(link.href, function (data) {
+            $popup_title.html($(link).html());
+            $popup_contents.html(data);
+            $popup_contents.find('form').append(csrf_input);
+        });
+    });
+});

http://git-wip-us.apache.org/repos/asf/allura/blob/46a4f68e/Allura/allura/lib/widgets/resources/js/admin_tool_delete_modal.js
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/resources/js/admin_tool_delete_modal.js b/Allura/allura/lib/widgets/resources/js/admin_tool_delete_modal.js
new file mode 100644
index 0000000..3d41261
--- /dev/null
+++ b/Allura/allura/lib/widgets/resources/js/admin_tool_delete_modal.js
@@ -0,0 +1,40 @@
+/*
+       Licensed to the Apache Software Foundation (ASF) under one
+       or more contributor license agreements.  See the NOTICE file
+       distributed with this work for additional information
+       regarding copyright ownership.  The ASF licenses this file
+       to you under the Apache License, Version 2.0 (the
+       "License"); you may not use this file except in compliance
+       with the License.  You may obtain a copy of the License at
+
+         http://www.apache.org/licenses/LICENSE-2.0
+
+       Unless required by applicable law or agreed to in writing,
+       software distributed under the License is distributed on an
+       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+       KIND, either express or implied.  See the License for the
+       specific language governing permissions and limitations
+       under the License.
+*/
+$(function() {
+  var $form = $('#admin-tool-delete-modal-form');
+  $('a.admin_tool_delete_modal').click(function() {
+    var mount_point = $(this).data('mount-point');
+    $form.find('.mount_point').val(mount_point);
+    var tool_label = 'this';
+    if (mount_point) {
+      tool_label = 'the "' + mount_point + '"';
+    }
+    var msg = 'Warning: This will destroy all data in ';
+    msg += tool_label;
+    msg += ' tool and is irreversible!';
+    $form.find('.warning-msg').text(msg);
+  });
+  $form.find('.delete-tool').click(function() {
+    if ($form.find('.mount_point').val()) {
+      $form.submit();
+    } else {
+      console.log('Do not know which tool to delete!');
+    }
+  });
+});

http://git-wip-us.apache.org/repos/asf/allura/blob/46a4f68e/Allura/allura/public/nf/js/project_tools.js
----------------------------------------------------------------------
diff --git a/Allura/allura/public/nf/js/project_tools.js b/Allura/allura/public/nf/js/project_tools.js
index a690937..c235f05 100644
--- a/Allura/allura/public/nf/js/project_tools.js
+++ b/Allura/allura/public/nf/js/project_tools.js
@@ -18,9 +18,6 @@
 */
 
 (function() {
-    // Provide CSRF protection
-    var cval = $.cookie('_session_id');
-    var csrf_input = $('<input name="_session_id" type="hidden" value="'+cval+'">');
     // Install popup
     var install_popup = $('#lightbox_install_modal');
     var install_form = $('#install_form');
@@ -50,42 +47,6 @@
             new_mount_label.val('');
         }
     });
-    // Edit popup
-    var $popup_title = $('#popup_title');
-    var $popup_contents = $('#popup_contents');
-    $('a.admin_modal').click(function () {
-        var link = this;
-        $popup_title.html('');
-        $popup_contents.html('Loading...');
-        $.get(link.href, function (data) {
-            $popup_title.html($(link).html());
-            $popup_contents.html(data);
-            $popup_contents.find('form').append(csrf_input);
-        });
-    });
-    // delete popup
-    var form_to_delete = null;
-    var mount_delete_popup = $('#lightbox_mount_delete');
-    var mount_delete_form = $('#mount_delete_form');
-    mount_delete_popup.append(mount_delete_form.show());
-    mount_delete_form.find('.continue_delete').click(function () {
-        form_to_delete.submit();
-        form_to_delete = null;
-    });
-    mount_delete_form.find('.cancel_delete').click(function () {
-        form_to_delete = null;
-    });
-    $('a.mount_delete').click(function () {
-        var tool_label = 'this';
-        var mount_point = $(this).data('mount-point');
-        if (mount_point) {
-            tool_label = 'the "' + mount_point + '"';
-        }
-        $('div.warning_msg').text('Warning: This will destroy all data in ' + tool_label + ' tool and is irreversible!');
-
-        form_to_delete = this.parentNode;
-        return false;
-    });
     // sorting
     $('#sortable').sortable({items: ".fleft:not(.isnt_sorted)"}).bind( "sortupdate", function (e) {
         var sortables = $('#sortable .fleft');

http://git-wip-us.apache.org/repos/asf/allura/blob/46a4f68e/Allura/allura/templates/jinja_master/sidebar_menu.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/jinja_master/sidebar_menu.html b/Allura/allura/templates/jinja_master/sidebar_menu.html
index b51a15b..9a81035 100644
--- a/Allura/allura/templates/jinja_master/sidebar_menu.html
+++ b/Allura/allura/templates/jinja_master/sidebar_menu.html
@@ -54,6 +54,17 @@
       {% endfor %}
     {% endif %}
     {% if c.app %}
+      {% if h.has_access(c.app, 'admin')() %}
+        {% for s in c.app.admin_menu() %}
+          {{sidebar_item(s)}}
+        {% endfor %}
+        {{sidebar_item(c.app.admin_menu_delete_button)}}
+        {{sidebar_item(None)}}
+        {{c.app.admin_modal.display()}}
+        {% if c.app.admin_menu_delete_button %}
+          {{c.app.admin_tool_delete_modal.display()}}
+        {% endif %}
+      {% endif %}
       {% for s in c.app.sidebar_menu() %}
         {{sidebar_item(s)}}
       {% endfor %}

http://git-wip-us.apache.org/repos/asf/allura/blob/46a4f68e/Allura/allura/templates/widgets/admin_tool_delete_modal.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/widgets/admin_tool_delete_modal.html b/Allura/allura/templates/widgets/admin_tool_delete_modal.html
new file mode 100644
index 0000000..dd8aab4
--- /dev/null
+++ b/Allura/allura/templates/widgets/admin_tool_delete_modal.html
@@ -0,0 +1,34 @@
+{#-
+       Licensed to the Apache Software Foundation (ASF) under one
+       or more contributor license agreements.  See the NOTICE file
+       distributed with this work for additional information
+       regarding copyright ownership.  The ASF licenses this file
+       to you under the Apache License, Version 2.0 (the
+       "License"); you may not use this file except in compliance
+       with the License.  You may obtain a copy of the License at
+
+         http://www.apache.org/licenses/LICENSE-2.0
+
+       Unless required by applicable law or agreed to in writing,
+       software distributed under the License is distributed on an
+       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+       KIND, either express or implied.  See the License for the
+       specific language governing permissions and limitations
+       under the License.
+-#}
+{% import 'allura:templates/jinja_master/lib.html' as lib with context %}
+
+<h1>Confirm Delete</h1>
+<form method="POST"
+      action="{{c.project.url()}}admin/update_mounts"
+      id="admin-tool-delete-modal-form">
+<p class="warning-msg">Warning: This will destroy all data in this tool and is irreversible!</p>
+<hr>
+<p>
+  <input type="button" value="Delete" class="delete-tool">
+  <input type="button" value="Cancel" class="close">
+</p>
+<input type="hidden" class="mount_point" name="tool-0.mount_point"/>
+<input name="tool-0.delete" type="hidden" value="Delete"/>
+{{lib.csrf_token()}}
+</form>


[02/14] allura git commit: [#7922] ticket:826 Make menu collapsible

Posted by br...@apache.org.
[#7922] ticket:826 Make menu collapsible


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

Branch: refs/heads/master
Commit: 8a5023570e43c5fb119cc3c4871bf61f1f4c0925
Parents: fd2cfa2
Author: Igor Bondarenko <je...@gmail.com>
Authored: Fri Jul 31 13:33:43 2015 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon Aug 17 17:54:12 2015 +0000

----------------------------------------------------------------------
 Allura/allura/app.py                            |  9 +++++++++
 .../templates/jinja_master/sidebar_menu.html    | 20 ++++++++++++++++++++
 2 files changed, 29 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/8a502357/Allura/allura/app.py
----------------------------------------------------------------------
diff --git a/Allura/allura/app.py b/Allura/allura/app.py
index 5d76459..22dbd84 100644
--- a/Allura/allura/app.py
+++ b/Allura/allura/app.py
@@ -626,6 +626,15 @@ class Application(object):
         return links
 
     @LazyProperty
+    def admin_menu_collapse_button(self):
+        return SitemapEntry(
+            label='Admin',
+            url='#',
+            extra_html_attrs={
+                'id': 'sidebar-admin-menu-trigger',
+            })
+
+    @LazyProperty
     def admin_menu_delete_button(self):
         anchored_tools = self.project.neighborhood.get_anchored_tools()
         anchored = self.tool_label.lower() in anchored_tools.keys()

http://git-wip-us.apache.org/repos/asf/allura/blob/8a502357/Allura/allura/templates/jinja_master/sidebar_menu.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/jinja_master/sidebar_menu.html b/Allura/allura/templates/jinja_master/sidebar_menu.html
index 9a81035..752440c 100644
--- a/Allura/allura/templates/jinja_master/sidebar_menu.html
+++ b/Allura/allura/templates/jinja_master/sidebar_menu.html
@@ -55,7 +55,26 @@
     {% endif %}
     {% if c.app %}
       {% if h.has_access(c.app, 'admin')() %}
+        <style>
+          #sidebar-admin-menu.hide ul li:not(:first-child) {
+            display: none;
+          }
+          #sidebar-admin-menu.hide ul li:first-child {
+            border-bottom: medium none;
+          }
+        </style>
+        <div id='sidebar-admin-menu' class='hide'>
         {% for s in c.app.admin_menu() %}
+          {% if loop.first %}
+            {{sidebar_item(c.app.admin_menu_collapse_button)}}
+            <script>
+              $('#sidebar-admin-menu-trigger').click(function(e) {
+                e.preventDefault();
+                $(this).parents('li').toggleClass('active');
+                $('#sidebar-admin-menu').toggleClass('hide');
+              });
+            </script>
+          {% endif %}
           {{sidebar_item(s)}}
         {% endfor %}
         {{sidebar_item(c.app.admin_menu_delete_button)}}
@@ -64,6 +83,7 @@
         {% if c.app.admin_menu_delete_button %}
           {{c.app.admin_tool_delete_modal.display()}}
         {% endif %}
+        </div>
       {% endif %}
       {% for s in c.app.sidebar_menu() %}
         {{sidebar_item(s)}}


[04/14] allura git commit: [#7922] ticket:826 Fix subproject delete

Posted by br...@apache.org.
[#7922] ticket:826 Fix subproject delete


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

Branch: refs/heads/master
Commit: e5b3959dfd45be16b76127dd8787d570049a0ed7
Parents: 46a4f68
Author: Igor Bondarenko <je...@gmail.com>
Authored: Fri Jul 31 12:28:21 2015 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon Aug 17 17:54:12 2015 +0000

----------------------------------------------------------------------
 Allura/allura/ext/admin/templates/project_tools.html        | 4 +++-
 .../lib/widgets/resources/js/admin_tool_delete_modal.js     | 9 ++++++++-
 .../allura/templates/widgets/admin_tool_delete_modal.html   | 4 ++--
 3 files changed, 13 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/e5b3959d/Allura/allura/ext/admin/templates/project_tools.html
----------------------------------------------------------------------
diff --git a/Allura/allura/ext/admin/templates/project_tools.html b/Allura/allura/ext/admin/templates/project_tools.html
index c9eab4a..90c03d4 100644
--- a/Allura/allura/ext/admin/templates/project_tools.html
+++ b/Allura/allura/ext/admin/templates/project_tools.html
@@ -105,7 +105,9 @@
                         <img src="{{ g.theme.app_icon_url('subproject', 48) }}" alt="">
                     </li>
                     <li>
-                      <a href="#" data-mount-point="{{ mount['sub'].shortname }}" class="admin_tool_delete_modal">
+                      <a href="#" data-mount-point="{{ mount['sub'].shortname }}"
+                                  data-subproject="true"
+                                  class="admin_tool_delete_modal">
                         <span>Delete</span>
                       </a>
                     </li>

http://git-wip-us.apache.org/repos/asf/allura/blob/e5b3959d/Allura/allura/lib/widgets/resources/js/admin_tool_delete_modal.js
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/resources/js/admin_tool_delete_modal.js b/Allura/allura/lib/widgets/resources/js/admin_tool_delete_modal.js
index 3d41261..211f5ed 100644
--- a/Allura/allura/lib/widgets/resources/js/admin_tool_delete_modal.js
+++ b/Allura/allura/lib/widgets/resources/js/admin_tool_delete_modal.js
@@ -20,7 +20,14 @@ $(function() {
   var $form = $('#admin-tool-delete-modal-form');
   $('a.admin_tool_delete_modal').click(function() {
     var mount_point = $(this).data('mount-point');
-    $form.find('.mount_point').val(mount_point);
+    var is_sub = $(this).data('subproject');
+    var prefix = is_sub ? 'subproject-0' : 'tool-0';
+    var mount_point_name = prefix + (is_sub ? '.shortname' : '.mount_point');
+    var delete_name = prefix + '.delete';
+    $form.find('.mount_point')
+         .attr('name', mount_point_name)
+         .val(mount_point);
+    $form.find('.delete-input').attr('name', delete_name);
     var tool_label = 'this';
     if (mount_point) {
       tool_label = 'the "' + mount_point + '"';

http://git-wip-us.apache.org/repos/asf/allura/blob/e5b3959d/Allura/allura/templates/widgets/admin_tool_delete_modal.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/widgets/admin_tool_delete_modal.html b/Allura/allura/templates/widgets/admin_tool_delete_modal.html
index dd8aab4..692c582 100644
--- a/Allura/allura/templates/widgets/admin_tool_delete_modal.html
+++ b/Allura/allura/templates/widgets/admin_tool_delete_modal.html
@@ -28,7 +28,7 @@
   <input type="button" value="Delete" class="delete-tool">
   <input type="button" value="Cancel" class="close">
 </p>
-<input type="hidden" class="mount_point" name="tool-0.mount_point"/>
-<input name="tool-0.delete" type="hidden" value="Delete"/>
+<input type="hidden" class="mount_point">
+<input type="hidden" value="Delete" class="delete-input">
 {{lib.csrf_token()}}
 </form>


[07/14] allura git commit: [#7922] ticket:834 Change menu header to h3/link

Posted by br...@apache.org.
[#7922] ticket:834 Change menu header to h3/link


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

Branch: refs/heads/master
Commit: 43dcbc43e8f5f42774685079a80bf2a81f1fede6
Parents: 0ebdb9c
Author: Igor Bondarenko <je...@gmail.com>
Authored: Thu Aug 13 18:37:58 2015 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon Aug 17 17:54:14 2015 +0000

----------------------------------------------------------------------
 Allura/allura/app.py                            |  1 -
 Allura/allura/nf/allura/css/allura.css          |  4 ++-
 .../templates/jinja_master/sidebar_menu.html    | 35 ++++++--------------
 3 files changed, 14 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/43dcbc43/Allura/allura/app.py
----------------------------------------------------------------------
diff --git a/Allura/allura/app.py b/Allura/allura/app.py
index 5e19ed1..2829ab6 100644
--- a/Allura/allura/app.py
+++ b/Allura/allura/app.py
@@ -632,7 +632,6 @@ class Application(object):
         """Returns button for showing/hiding admin sidebar menu"""
         return SitemapEntry(
             label='Admin',
-            url='#',
             extra_html_attrs={
                 'id': 'sidebar-admin-menu-trigger',
             })

http://git-wip-us.apache.org/repos/asf/allura/blob/43dcbc43/Allura/allura/nf/allura/css/allura.css
----------------------------------------------------------------------
diff --git a/Allura/allura/nf/allura/css/allura.css b/Allura/allura/nf/allura/css/allura.css
index 17ee342..2fb97ed 100644
--- a/Allura/allura/nf/allura/css/allura.css
+++ b/Allura/allura/nf/allura/css/allura.css
@@ -86,4 +86,6 @@ tr.rev div.markdown_content p {
 
 #phone_verification_overlay iframe {
     height: 320px;
-}
\ No newline at end of file
+}
+
+#sidebar-admin-header { cursor: pointer; }

http://git-wip-us.apache.org/repos/asf/allura/blob/43dcbc43/Allura/allura/templates/jinja_master/sidebar_menu.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/jinja_master/sidebar_menu.html b/Allura/allura/templates/jinja_master/sidebar_menu.html
index 752440c..4505804 100644
--- a/Allura/allura/templates/jinja_master/sidebar_menu.html
+++ b/Allura/allura/templates/jinja_master/sidebar_menu.html
@@ -55,35 +55,22 @@
     {% endif %}
     {% if c.app %}
       {% if h.has_access(c.app, 'admin')() %}
-        <style>
-          #sidebar-admin-menu.hide ul li:not(:first-child) {
-            display: none;
-          }
-          #sidebar-admin-menu.hide ul li:first-child {
-            border-bottom: medium none;
-          }
-        </style>
-        <div id='sidebar-admin-menu' class='hide'>
-        {% for s in c.app.admin_menu() %}
-          {% if loop.first %}
+        {% if c.app.admin_menu() %}
+          <a id='sidebar-admin-header' onclick='$("#sidebar-admin-menu").toggleClass("hidden");'>
             {{sidebar_item(c.app.admin_menu_collapse_button)}}
-            <script>
-              $('#sidebar-admin-menu-trigger').click(function(e) {
-                e.preventDefault();
-                $(this).parents('li').toggleClass('active');
-                $('#sidebar-admin-menu').toggleClass('hide');
-              });
-            </script>
-          {% endif %}
-          {{sidebar_item(s)}}
-        {% endfor %}
-        {{sidebar_item(c.app.admin_menu_delete_button)}}
-        {{sidebar_item(None)}}
+          </a>
+          <div id='sidebar-admin-menu' class='hidden'>
+            {% for s in c.app.admin_menu() %}
+              {{sidebar_item(s)}}
+            {% endfor %}
+            {{sidebar_item(c.app.admin_menu_delete_button)}}
+            {{sidebar_item(None)}}
+          </div>
+        {% endif %}
         {{c.app.admin_modal.display()}}
         {% if c.app.admin_menu_delete_button %}
           {{c.app.admin_tool_delete_modal.display()}}
         {% endif %}
-        </div>
       {% endif %}
       {% for s in c.app.sidebar_menu() %}
         {{sidebar_item(s)}}


[09/14] allura git commit: [#7922] ticket:834 Don't show admin options twice on sidebar when left bar is hidden

Posted by br...@apache.org.
[#7922] ticket:834 Don't show admin options twice on sidebar when left bar is hidden


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

Branch: refs/heads/master
Commit: dd86014e039a66ab4bedf4e3acef976934f737b8
Parents: 41f60b9
Author: Igor Bondarenko <je...@gmail.com>
Authored: Thu Aug 13 19:12:47 2015 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon Aug 17 17:54:14 2015 +0000

----------------------------------------------------------------------
 .../templates/jinja_master/sidebar_menu.html       | 17 +++++++++++------
 ForgeWiki/forgewiki/wiki_main.py                   |  4 ++--
 2 files changed, 13 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/dd86014e/Allura/allura/templates/jinja_master/sidebar_menu.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/jinja_master/sidebar_menu.html b/Allura/allura/templates/jinja_master/sidebar_menu.html
index 4505804..64102fc 100644
--- a/Allura/allura/templates/jinja_master/sidebar_menu.html
+++ b/Allura/allura/templates/jinja_master/sidebar_menu.html
@@ -55,21 +55,26 @@
     {% endif %}
     {% if c.app %}
       {% if h.has_access(c.app, 'admin')() %}
-        {% if c.app.admin_menu() %}
+        {% if c.app.tool_label.lower() == 'wiki' %}
+          {% set admin_menu = c.app.admin_menu(skip_common_menu=True) %}
+        {% else %}
+          {% set admin_menu = c.app.admin_menu() %}
+        {% endif %}
+        {% if admin_menu %}
           <a id='sidebar-admin-header' onclick='$("#sidebar-admin-menu").toggleClass("hidden");'>
             {{sidebar_item(c.app.admin_menu_collapse_button)}}
           </a>
           <div id='sidebar-admin-menu' class='hidden'>
-            {% for s in c.app.admin_menu() %}
+            {% for s in admin_menu %}
               {{sidebar_item(s)}}
             {% endfor %}
             {{sidebar_item(c.app.admin_menu_delete_button)}}
             {{sidebar_item(None)}}
           </div>
-        {% endif %}
-        {{c.app.admin_modal.display()}}
-        {% if c.app.admin_menu_delete_button %}
-          {{c.app.admin_tool_delete_modal.display()}}
+          {{c.app.admin_modal.display()}}
+          {% if c.app.admin_menu_delete_button %}
+            {{c.app.admin_tool_delete_modal.display()}}
+          {% endif %}
         {% endif %}
       {% endif %}
       {% for s in c.app.sidebar_menu() %}

http://git-wip-us.apache.org/repos/asf/allura/blob/dd86014e/ForgeWiki/forgewiki/wiki_main.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/wiki_main.py b/ForgeWiki/forgewiki/wiki_main.py
index d23cff8..e8dae94 100644
--- a/ForgeWiki/forgewiki/wiki_main.py
+++ b/ForgeWiki/forgewiki/wiki_main.py
@@ -257,7 +257,7 @@ The wiki uses [Markdown](%s) syntax.
                       SitemapEntry('Formatting Help', self.url + 'markdown_syntax/')]
         return links
 
-    def admin_menu(self):
+    def admin_menu(self, skip_common_menu=False):
         admin_url = c.project.url() + \
             'admin/' + \
             self.config.options.mount_point + '/'
@@ -265,7 +265,7 @@ The wiki uses [Markdown](%s) syntax.
                               admin_url + 'home',
                               className='admin_modal')]
 
-        if not self.show_left_bar:
+        if not self.show_left_bar and not skip_common_menu:
             links += self.create_common_wiki_menu(True,
                                                   admin_url +
                                                   'create_wiki_page',


[06/14] allura git commit: [#7922] ticket:826 Fix tests

Posted by br...@apache.org.
[#7922] ticket:826 Fix tests


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

Branch: refs/heads/master
Commit: 906259792f93c4b7a4c4898ac7aba04837b52436
Parents: 8a50235
Author: Igor Bondarenko <je...@gmail.com>
Authored: Mon Aug 3 13:21:53 2015 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon Aug 17 17:54:13 2015 +0000

----------------------------------------------------------------------
 .../tests/functional/test_neighborhood.py       |  2 +-
 AlluraTest/alluratest/controller.py             |  6 ++
 .../tests/functional/test_controllers.py        | 13 +++--
 .../forgetracker/tests/functional/test_root.py  | 61 ++++++++++++--------
 .../forgewiki/tests/functional/test_rest.py     |  2 +-
 .../forgewiki/tests/functional/test_root.py     |  9 ++-
 6 files changed, 60 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/90625979/Allura/allura/tests/functional/test_neighborhood.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_neighborhood.py b/Allura/allura/tests/functional/test_neighborhood.py
index 9359efc..8b6a74f 100644
--- a/Allura/allura/tests/functional/test_neighborhood.py
+++ b/Allura/allura/tests/functional/test_neighborhood.py
@@ -173,7 +173,7 @@ class TestNeighborhood(TestController):
 
         r = self.app.get('/p/test/admin/tools')
         assert '<div class="fleft isnt_sorted">' in r
-        delete_tool = r.html.find('a', {'class': 'mount_delete'})
+        delete_tool = r.html.findAll('a', {'class': 'admin_tool_delete_modal'})
         assert_equal(len(delete_tool), 1)
 
     def test_show_title(self):

http://git-wip-us.apache.org/repos/asf/allura/blob/90625979/AlluraTest/alluratest/controller.py
----------------------------------------------------------------------
diff --git a/AlluraTest/alluratest/controller.py b/AlluraTest/alluratest/controller.py
index 5a61ab7..babf262 100644
--- a/AlluraTest/alluratest/controller.py
+++ b/AlluraTest/alluratest/controller.py
@@ -185,6 +185,12 @@ class TestController(object):
         json_dict = json_dict.strip(' ;')
         return json.loads(json_dict)
 
+    def find_form(self, resp, cond):
+        """Find form on the page that meets given condition"""
+        for f in resp.forms.itervalues():
+            if cond(f):
+                return f
+
 
 class TestRestApiBase(TestController):
 

http://git-wip-us.apache.org/repos/asf/allura/blob/90625979/ForgeGit/forgegit/tests/functional/test_controllers.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/functional/test_controllers.py b/ForgeGit/forgegit/tests/functional/test_controllers.py
index 4c363d2..dcc975f 100644
--- a/ForgeGit/forgegit/tests/functional/test_controllers.py
+++ b/ForgeGit/forgegit/tests/functional/test_controllers.py
@@ -574,10 +574,15 @@ class TestFork(_TestCase):
         r = self._follow(r, **kw)
         return r
 
+    def _find_request_merge_form(self, resp):
+        cond = lambda f: f.action == 'do_request_merge'
+        return self.find_form(resp, cond)
+
     def _request_merge(self, **kw):
         r = self.app.get('/p/test2/code/request_merge', **kw)
         r = self._follow(r, **kw)
-        r = r.forms[0].submit()
+        form = self._find_request_merge_form(r)
+        r = form.submit()
         r = self._follow(r, **kw)
         mr_num = r.request.url.split('/')[-2]
         assert mr_num.isdigit(), mr_num
@@ -640,7 +645,7 @@ class TestFork(_TestCase):
         assert 'git checkout master' in merge_instructions
         assert 'git fetch git://git.localhost/p/test2/code master' in merge_instructions
         assert 'git merge {}'.format(c_id) in merge_instructions
-        assert_in('less than 1 minute ago', r.html.findAll('p')[0].getText())
+        assert_in('less than 1 minute ago', r.html.findAll('p')[2].getText())
 
         merge_form = r.html.find('form', action='merge')
         assert merge_form
@@ -669,8 +674,8 @@ class TestFork(_TestCase):
         r, mr_num = self._request_merge()
         r = self.app.get('/p/test/src-git/merge-requests/')
         assert 'href="%s/"' % mr_num in r, r
-        assert_equal(r.html.findAll('span')[8].getText(), 'less than 1 minute ago')
-        assert_equal(r.html.findAll('span')[9].getText(), 'less than 1 minute ago')
+        assert_equal(r.html.findAll('span')[-2].getText(), 'less than 1 minute ago')
+        assert_equal(r.html.findAll('span')[-1].getText(), 'less than 1 minute ago')
 
     def test_merge_request_update_status(self):
         r, mr_num = self._request_merge()

http://git-wip-us.apache.org/repos/asf/allura/blob/90625979/ForgeTracker/forgetracker/tests/functional/test_root.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tests/functional/test_root.py b/ForgeTracker/forgetracker/tests/functional/test_root.py
index 47c9aab..351b80b 100644
--- a/ForgeTracker/forgetracker/tests/functional/test_root.py
+++ b/ForgeTracker/forgetracker/tests/functional/test_root.py
@@ -27,6 +27,7 @@ import allura
 import mock
 
 import PIL
+from BeautifulSoup import BeautifulSoup
 from mock import patch
 from nose.tools import (
     assert_true,
@@ -65,11 +66,19 @@ class TrackerTestController(TestController):
     def setup_with_tools(self):
         pass
 
+    def _find_new_ticket_form(self, resp):
+        cond = lambda f: f.action.endswith('/save_ticket')
+        return self.find_form(resp, cond)
+
+    def _find_update_ticket_form(self, resp):
+        cond = lambda f: f.action.endswith('/update_ticket_from_widget')
+        return self.find_form(resp, cond)
+
     def new_ticket(self, mount_point='/bugs/', extra_environ=None, **kw):
         extra_environ = extra_environ or {}
         response = self.app.get(mount_point + 'new/',
                                 extra_environ=extra_environ)
-        form = response.forms[1]
+        form = self._find_new_ticket_form(response)
         # If this is ProjectUserCombo's select populate it
         # with all the users in the project. This is a workaround for tests,
         # in real enviroment this is populated via ajax.
@@ -346,7 +355,7 @@ class TestFunctionalController(TrackerTestController):
 
     def test_new_ticket_form(self):
         response = self.app.get('/bugs/new/')
-        form = response.forms[1]
+        form = self._find_new_ticket_form(response)
         form['ticket_form.summary'] = 'test new ticket form'
         form['ticket_form.description'] = 'test new ticket form description'
         response = form.submit().follow()
@@ -841,7 +850,8 @@ class TestFunctionalController(TrackerTestController):
         }, upload_files=[upload]).follow()
         assert file_name in ticket_editor, ticket_editor.showbrowser()
         req = self.app.get('/bugs/1/')
-        file_link = req.html.findAll('form')[1].findAll('a')[1]
+        form = self._find_update_ticket_form(req)
+        file_link = BeautifulSoup(form.text).findAll('a')[1]
         assert_equal(file_link.string, file_name)
         self.app.post(str(file_link['href']), {
             'delete': 'True'
@@ -883,7 +893,8 @@ class TestFunctionalController(TrackerTestController):
         ticket_editor = self.app.post('/bugs/1/update_ticket', {
             'summary': 'zzz'
         }, upload_files=[upload]).follow()
-        download = self.app.get(str(ticket_editor.html.findAll('form')[1].findAll('a')[1]['href']))
+        form = self._find_update_ticket_form(ticket_editor)
+        download = self.app.get(str(BeautifulSoup(form.text).findAll('a')[1]['href']))
         assert_equal(download.body, file_data)
 
     def test_two_attachments(self):
@@ -1229,18 +1240,17 @@ class TestFunctionalController(TrackerTestController):
             '/admin/bugs/set_custom_fields', params=variable_encode(params))
         # Test new ticket form
         r = self.app.get('/bugs/new/')
-        form = r.forms[1]
+        form = self._find_new_ticket_form(r)
         form['ticket_form.custom_fields._priority'] = 'urgent'
         form['ticket_form.custom_fields._category'] = 'bugs'
         error_form = form.submit()
-        assert_equal(error_form.forms[1]['ticket_form.custom_fields._priority'].value,
-                     'urgent')
-        assert_equal(error_form.forms[1]['ticket_form.custom_fields._category'].value,
-                     'bugs')
+        form = self._find_new_ticket_form(error_form)
+        assert_equal(form['ticket_form.custom_fields._priority'].value, 'urgent')
+        assert_equal(form['ticket_form.custom_fields._category'].value, 'bugs')
         # Test edit ticket form
         self.new_ticket(summary='Test ticket')
         response = self.app.get('/bugs/1/')
-        form = response.forms[1]
+        form = self._find_update_ticket_form(response)
         assert_equal(
             form['ticket_form.custom_fields._priority'].value, 'normal')
         assert_equal(form['ticket_form.custom_fields._category'].value, '')
@@ -1248,29 +1258,29 @@ class TestFunctionalController(TrackerTestController):
         form['ticket_form.custom_fields._priority'] = 'urgent'
         form['ticket_form.custom_fields._category'] = 'bugs'
         error_form = form.submit()
-        assert_equal(error_form.forms[1]['ticket_form.custom_fields._priority'].value,
-                     'urgent')
-        assert_equal(error_form.forms[1]['ticket_form.custom_fields._category'].value,
-                     'bugs')
+        form = self._find_update_ticket_form(error_form)
+        assert_equal(form['ticket_form.custom_fields._priority'].value, 'urgent')
+        assert_equal(form['ticket_form.custom_fields._category'].value, 'bugs')
 
     def test_new_ticket_validation(self):
         summary = 'ticket summary'
         response = self.app.get('/bugs/new/')
         assert not response.html.find('div', {'class': 'error'})
-        form = response.forms[1]
+        form = self._find_new_ticket_form(response)
         form['ticket_form.labels'] = 'foo'
         # try submitting with no summary set and check for error message
         error_form = form.submit()
-        assert error_form.forms[1]['ticket_form.labels'].value == 'foo'
-        error_message = error_form.html.find('div', {'class': 'error'})
+        form = self._find_new_ticket_form(error_form)
+        assert form['ticket_form.labels'].value == 'foo'
+        error_message = BeautifulSoup(form.text).find('div', {'class': 'error'})
         assert error_message
         assert (error_message.string == 'You must provide a Title' or
                 error_message.string == 'Missing value')
         assert error_message.findPreviousSibling('input').get('name') == 'ticket_form.summary'
         # set a summary, submit, and check for success
-        error_form.forms[1]['ticket_form.summary'] = summary
-        success = error_form.forms[1].submit().follow().html
-        assert success.findAll('form')[1].get('action') == '/p/test/bugs/1/update_ticket_from_widget'
+        form['ticket_form.summary'] = summary
+        success = form.submit().follow().html
+        assert success.findAll('form', {'action': '/p/test/bugs/1/update_ticket_from_widget'}) is not None
         assert success.find('input', {'name': 'ticket_form.summary'})['value'] == summary
 
     def test_edit_ticket_validation(self):
@@ -1281,7 +1291,7 @@ class TestFunctionalController(TrackerTestController):
         # check that existing form is valid
         assert response.html.find('input', {'name': 'ticket_form.summary'})['value'] == old_summary
         assert not response.html.find('div', {'class': 'error'})
-        form = response.forms[1]
+        form = self._find_update_ticket_form(response)
         # try submitting with no summary set and check for error message
         form['ticket_form.summary'] = ""
         error_form = form.submit()
@@ -1290,11 +1300,12 @@ class TestFunctionalController(TrackerTestController):
         assert error_message.string == 'You must provide a Title'
         assert error_message.findPreviousSibling('input').get('name') == 'ticket_form.summary'
         # set a summary, submit, and check for success
-        error_form.forms[1]['ticket_form.summary'] = new_summary
-        r = error_form.forms[1].submit()
+        form = self._find_update_ticket_form(error_form)
+        form['ticket_form.summary'] = new_summary
+        r = form.submit()
         assert r.status_int == 302, r.showbrowser()
         success = r.follow().html
-        assert success.findAll('form')[1].get('action') == '/p/test/bugs/1/update_ticket_from_widget'
+        assert success.findAll('form', {'action': '/p/test/bugs/1/update_ticket_from_widget'}) is not None
         assert success.find('input', {'name': 'ticket_form.summary'})['value'] == new_summary
 
     def test_home(self):
@@ -2721,7 +2732,7 @@ class TestCustomUserField(TrackerTestController):
     def test_change_user_field(self):
         kw = {'custom_fields._code_review': ''}
         r = self.new_ticket(summary='test custom fields', **kw).follow()
-        f = r.forms[1]
+        f = self._find_update_ticket_form(r)
         # Populate ProjectUserCombo's select with option we want.
         # This is a workaround for tests,
         # in real enviroment this is populated via ajax.

http://git-wip-us.apache.org/repos/asf/allura/blob/90625979/ForgeWiki/forgewiki/tests/functional/test_rest.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/tests/functional/test_rest.py b/ForgeWiki/forgewiki/tests/functional/test_rest.py
index 6a5de3b..a2b58ae 100644
--- a/ForgeWiki/forgewiki/tests/functional/test_rest.py
+++ b/ForgeWiki/forgewiki/tests/functional/test_rest.py
@@ -42,7 +42,7 @@ class TestWikiApi(TestRestApiBase):
 
     def test_get_page(self):
         r = self.app.get('/p/test/wiki/Home/')
-        discussion_url = r.html.findAll('form')[2]['action'][:-4]
+        discussion_url = r.html.findAll('form')[3]['action'][:-4]
         content = file(__file__).read()
         self.app.post('/wiki/Home/attach',
                       upload_files=[('file_info', 'test_root.py', content)])

http://git-wip-us.apache.org/repos/asf/allura/blob/90625979/ForgeWiki/forgewiki/tests/functional/test_root.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/tests/functional/test_root.py b/ForgeWiki/forgewiki/tests/functional/test_root.py
index 3f69d89..276c4b9 100644
--- a/ForgeWiki/forgewiki/tests/functional/test_root.py
+++ b/ForgeWiki/forgewiki/tests/functional/test_root.py
@@ -54,6 +54,10 @@ class TestRootController(TestController):
     def setup_with_tools(self):
         pass
 
+    def _find_edit_form(self, resp):
+        cond = lambda f: f.id == 'page_edit_form'
+        return self.find_form(resp, cond)
+
     def test_root_index(self):
         page_url = h.urlquote(u'/wiki/tést/')
         r = self.app.get(page_url).follow()
@@ -678,8 +682,9 @@ class TestRootController(TestController):
         assert 'The resource was found at http://localhost/p/test/wiki/Home/;' in self.app.get(
             '/p/test/wiki/')
         req = self.app.get('/p/test/wiki/Home/edit')
-        req.forms[1]['title'].value = 'new_title'
-        req.forms[1].submit()
+        form = self._find_edit_form(req)
+        form['title'].value = 'new_title'
+        form.submit()
         assert 'The resource was found at http://localhost/p/test/wiki/new_title/;' in self.app.get(
             '/p/test/wiki/')
 


[05/14] allura git commit: [#7922] ticket:826 Add tests for sitebar admin menu

Posted by br...@apache.org.
[#7922] ticket:826 Add tests for sitebar admin menu


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

Branch: refs/heads/master
Commit: 7a0141c1159ede8bc8d8722be56824fa459b158e
Parents: 9062597
Author: Igor Bondarenko <je...@gmail.com>
Authored: Mon Aug 3 13:37:56 2015 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon Aug 17 17:54:13 2015 +0000

----------------------------------------------------------------------
 ForgeWiki/forgewiki/tests/functional/test_root.py | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/7a0141c1/ForgeWiki/forgewiki/tests/functional/test_root.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/tests/functional/test_root.py b/ForgeWiki/forgewiki/tests/functional/test_root.py
index 276c4b9..e2604bc 100644
--- a/ForgeWiki/forgewiki/tests/functional/test_root.py
+++ b/ForgeWiki/forgewiki/tests/functional/test_root.py
@@ -819,3 +819,20 @@ class TestRootController(TestController):
                 'Page creation rate limit exceeded. Please try again later.')
             p = model.Page.query.get(title='page2')
             assert_equal(p, None)
+
+    def test_sidebar_admin_menu(self):
+        r = self.app.get('/p/test/wiki/Home/')
+        menu = r.html.find('div', {'id': 'sidebar-admin-menu'})
+        menu = [li.find('span').getText() for li in menu.findAll('li')]
+        assert_equal(
+            menu,
+            ['Admin', 'Set Home', 'Permissions', 'Options', 'Label', 'Delete'])
+
+    def test_sidebar_admin_menu_invisible_to_not_admin(self):
+        def assert_invisible_for(username):
+            env = {'username': username}
+            r = self.app.get('/p/test/wiki/Home/', extra_environ=env)
+            menu = r.html.find('div', {'id': 'sidebar-admin-menu'})
+            assert_equal(menu, None)
+        assert_invisible_for('*anonymous')
+        assert_invisible_for('test-user')


[12/14] allura git commit: [#7922] ticket:834 Fix one more test

Posted by br...@apache.org.
[#7922] ticket:834 Fix one more test


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

Branch: refs/heads/master
Commit: 37f2d48e977668c101e713cb8a25d3fe432297cd
Parents: 9aab61d
Author: Igor Bondarenko <je...@gmail.com>
Authored: Thu Aug 13 20:30:04 2015 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon Aug 17 17:54:15 2015 +0000

----------------------------------------------------------------------
 ForgeWiki/forgewiki/tests/functional/test_root.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/37f2d48e/ForgeWiki/forgewiki/tests/functional/test_root.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/tests/functional/test_root.py b/ForgeWiki/forgewiki/tests/functional/test_root.py
index e2604bc..a42bce6 100644
--- a/ForgeWiki/forgewiki/tests/functional/test_root.py
+++ b/ForgeWiki/forgewiki/tests/functional/test_root.py
@@ -826,7 +826,7 @@ class TestRootController(TestController):
         menu = [li.find('span').getText() for li in menu.findAll('li')]
         assert_equal(
             menu,
-            ['Admin', 'Set Home', 'Permissions', 'Options', 'Label', 'Delete'])
+            ['Set Home', 'Permissions', 'Options', 'Label', 'Delete'])
 
     def test_sidebar_admin_menu_invisible_to_not_admin(self):
         def assert_invisible_for(username):


[03/14] allura git commit: [#7922] ticket:826 Fix tool ordering

Posted by br...@apache.org.
[#7922] ticket:826 Fix tool ordering


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

Branch: refs/heads/master
Commit: fd2cfa2e728eaa712e2e6908196f74d4b8c1ae09
Parents: e5b3959
Author: Igor Bondarenko <je...@gmail.com>
Authored: Fri Jul 31 12:48:43 2015 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon Aug 17 17:54:12 2015 +0000

----------------------------------------------------------------------
 Allura/allura/ext/admin/templates/project_tools.html | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/fd2cfa2e/Allura/allura/ext/admin/templates/project_tools.html
----------------------------------------------------------------------
diff --git a/Allura/allura/ext/admin/templates/project_tools.html b/Allura/allura/ext/admin/templates/project_tools.html
index 90c03d4..aa825f1 100644
--- a/Allura/allura/ext/admin/templates/project_tools.html
+++ b/Allura/allura/ext/admin/templates/project_tools.html
@@ -92,9 +92,8 @@
                     {% endfor %}
                     {{sidebar_item(app.admin_menu_delete_button)}}
                 </ul>
-                {% if not app.uninstallable %}
-                  <input type="hidden" class="mount_point" value="{{mount['ac'].options.mount_point}}"/>
-                {% endif %}
+                {# for ordering #}
+                <input type="hidden" class="mount_point" value="{{mount['ac'].options.mount_point}}"/>
             </div>
         {% endif %}
         {% if 'sub' in mount and not mount['sub'].deleted %}


[11/14] allura git commit: [#7922] ticket:834 Add href="#" to sidebar admin header, so that tests won't fail

Posted by br...@apache.org.
[#7922] ticket:834 Add href="#" to sidebar admin header, so that tests won't fail


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

Branch: refs/heads/master
Commit: 9aab61d07fcdf4f9da98d31e93c648f61cf2c157
Parents: baa24c7
Author: Igor Bondarenko <je...@gmail.com>
Authored: Thu Aug 13 19:39:40 2015 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon Aug 17 17:54:15 2015 +0000

----------------------------------------------------------------------
 Allura/allura/templates/jinja_master/sidebar_menu.html | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/9aab61d0/Allura/allura/templates/jinja_master/sidebar_menu.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/jinja_master/sidebar_menu.html b/Allura/allura/templates/jinja_master/sidebar_menu.html
index 64102fc..80d37ac 100644
--- a/Allura/allura/templates/jinja_master/sidebar_menu.html
+++ b/Allura/allura/templates/jinja_master/sidebar_menu.html
@@ -61,7 +61,7 @@
           {% set admin_menu = c.app.admin_menu() %}
         {% endif %}
         {% if admin_menu %}
-          <a id='sidebar-admin-header' onclick='$("#sidebar-admin-menu").toggleClass("hidden");'>
+          <a id='sidebar-admin-header' onclick='$("#sidebar-admin-menu").toggleClass("hidden");return false;' href='#'>
             {{sidebar_item(c.app.admin_menu_collapse_button)}}
           </a>
           <div id='sidebar-admin-menu' class='hidden'>


[08/14] allura git commit: [#7922] ticket:834 Show tool label in admin menu header

Posted by br...@apache.org.
[#7922] ticket:834 Show tool label in admin menu header


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

Branch: refs/heads/master
Commit: 41f60b9e69291e4810fcf544b2bfa5f3e76cac1c
Parents: 43dcbc4
Author: Igor Bondarenko <je...@gmail.com>
Authored: Thu Aug 13 18:41:12 2015 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon Aug 17 17:54:14 2015 +0000

----------------------------------------------------------------------
 Allura/allura/app.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/41f60b9e/Allura/allura/app.py
----------------------------------------------------------------------
diff --git a/Allura/allura/app.py b/Allura/allura/app.py
index 2829ab6..a0542c4 100644
--- a/Allura/allura/app.py
+++ b/Allura/allura/app.py
@@ -631,7 +631,7 @@ class Application(object):
     def admin_menu_collapse_button(self):
         """Returns button for showing/hiding admin sidebar menu"""
         return SitemapEntry(
-            label='Admin',
+            label=u'Admin - {}'.format(self.config.options.mount_label),
             extra_html_attrs={
                 'id': 'sidebar-admin-menu-trigger',
             })


[13/14] allura git commit: [#7922] ticket:834 Fix admin/tools menu display when wiki left bar is hidden

Posted by br...@apache.org.
[#7922] ticket:834 Fix admin/tools menu display when wiki left bar is hidden


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

Branch: refs/heads/master
Commit: baa24c7f0719ffef7f776b997ef9dd594f9473df
Parents: dd86014
Author: Igor Bondarenko <je...@gmail.com>
Authored: Thu Aug 13 19:13:46 2015 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon Aug 17 17:54:15 2015 +0000

----------------------------------------------------------------------
 ForgeWiki/forgewiki/wiki_main.py | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/baa24c7f/ForgeWiki/forgewiki/wiki_main.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/wiki_main.py b/ForgeWiki/forgewiki/wiki_main.py
index e8dae94..a43be58 100644
--- a/ForgeWiki/forgewiki/wiki_main.py
+++ b/ForgeWiki/forgewiki/wiki_main.py
@@ -232,7 +232,7 @@ The wiki uses [Markdown](%s) syntax.
                       SitemapEntry('Wiki Home', self.url, className='wiki_home')]
         links += [SitemapEntry('Browse Pages', self.url + 'browse_pages/'),
                   SitemapEntry('Browse Labels', self.url + 'browse_tags/')]
-        discussion = c.app.config.discussion
+        discussion = self.config.discussion
         pending_mod_count = M.Post.query.find({
             'discussion_id': discussion._id,
             'status': 'pending',
@@ -250,8 +250,9 @@ The wiki uses [Markdown](%s) syntax.
                 subscribe_action.capitalize(),
                 '' if subscribed else ' to wiki')
             subscribe_url = '{}#toggle-subscribe'.format(self.url)
-            links += [SitemapEntry(''),
-                      SitemapEntry(subscribe_title, subscribe_url, ui_icon=g.icons['mail'])]
+            if not admin_menu:
+                links.append(SitemapEntry(None))
+            links.append(SitemapEntry(subscribe_title, subscribe_url, ui_icon=g.icons['mail']))
         if not admin_menu:
             links += [SitemapEntry(''),
                       SitemapEntry('Formatting Help', self.url + 'markdown_syntax/')]


[14/14] allura git commit: [#7922] set expand/collapse indicators and spacing for admin section of sidebar

Posted by br...@apache.org.
[#7922] set expand/collapse indicators and spacing for admin section of sidebar

Remove cursor:pointer since previous commit added href="#"


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

Branch: refs/heads/master
Commit: 7c5a5de5360a4d6beeb185cc1a220815fc2f214d
Parents: 37f2d48
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Mon Aug 17 19:02:25 2015 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon Aug 17 19:02:25 2015 +0000

----------------------------------------------------------------------
 Allura/allura/nf/allura/css/allura.css              | 16 +++++++++++++++-
 .../allura/templates/jinja_master/sidebar_menu.html |  2 +-
 2 files changed, 16 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/7c5a5de5/Allura/allura/nf/allura/css/allura.css
----------------------------------------------------------------------
diff --git a/Allura/allura/nf/allura/css/allura.css b/Allura/allura/nf/allura/css/allura.css
index 2fb97ed..4ddebc6 100644
--- a/Allura/allura/nf/allura/css/allura.css
+++ b/Allura/allura/nf/allura/css/allura.css
@@ -88,4 +88,18 @@ tr.rev div.markdown_content p {
     height: 320px;
 }
 
-#sidebar-admin-header { cursor: pointer; }
+/* give some space after sidebar admin link (except for its own section which starts with <div> instead of <ul>) */
+#sidebar-admin-header ~ ul:first-of-type {
+    margin-top: 20px;
+}
+/* expand/collapse indicator */
+#sidebar-admin-header h3::before {
+    content: '▸ ';
+}
+#sidebar-admin-header.expanded h3::before {
+    content: '▾ ';
+}
+#sidebar-admin-header h3 {
+    padding-left: 2px;
+}
+

http://git-wip-us.apache.org/repos/asf/allura/blob/7c5a5de5/Allura/allura/templates/jinja_master/sidebar_menu.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/jinja_master/sidebar_menu.html b/Allura/allura/templates/jinja_master/sidebar_menu.html
index 80d37ac..df06d18 100644
--- a/Allura/allura/templates/jinja_master/sidebar_menu.html
+++ b/Allura/allura/templates/jinja_master/sidebar_menu.html
@@ -61,7 +61,7 @@
           {% set admin_menu = c.app.admin_menu() %}
         {% endif %}
         {% if admin_menu %}
-          <a id='sidebar-admin-header' onclick='$("#sidebar-admin-menu").toggleClass("hidden");return false;' href='#'>
+          <a id='sidebar-admin-header' onclick='$("#sidebar-admin-menu").toggleClass("hidden");$("#sidebar-admin-header").toggleClass("expanded");return false;' href='#'>
             {{sidebar_item(c.app.admin_menu_collapse_button)}}
           </a>
           <div id='sidebar-admin-menu' class='hidden'>


[10/14] allura git commit: [#7922] ticket:826 Add docstrings for new properties

Posted by br...@apache.org.
[#7922] ticket:826 Add docstrings for new properties


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

Branch: refs/heads/master
Commit: 0ebdb9c7828353874fa9e87a14250bf3ecc09058
Parents: 7a0141c
Author: Igor Bondarenko <je...@gmail.com>
Authored: Mon Aug 3 13:46:11 2015 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon Aug 17 17:54:14 2015 +0000

----------------------------------------------------------------------
 Allura/allura/app.py | 4 ++++
 1 file changed, 4 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/0ebdb9c7/Allura/allura/app.py
----------------------------------------------------------------------
diff --git a/Allura/allura/app.py b/Allura/allura/app.py
index 22dbd84..5e19ed1 100644
--- a/Allura/allura/app.py
+++ b/Allura/allura/app.py
@@ -293,10 +293,12 @@ class Application(object):
 
     @LazyProperty
     def admin_modal(self):
+        """Returns modal dialog widget for app's admin options"""
         return admin_widgets.AdminModal()
 
     @LazyProperty
     def admin_tool_delete_modal(self):
+        """Returns modal dialog widget for app's delete workflow"""
         return admin_widgets.AdminToolDeleteModal()
 
     @LazyProperty
@@ -627,6 +629,7 @@ class Application(object):
 
     @LazyProperty
     def admin_menu_collapse_button(self):
+        """Returns button for showing/hiding admin sidebar menu"""
         return SitemapEntry(
             label='Admin',
             url='#',
@@ -636,6 +639,7 @@ class Application(object):
 
     @LazyProperty
     def admin_menu_delete_button(self):
+        """Returns button for deleting an app if app can be deleted"""
         anchored_tools = self.project.neighborhood.get_anchored_tools()
         anchored = self.tool_label.lower() in anchored_tools.keys()
         if self.uninstallable and not anchored: