allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [39/50] [abbrv] allura git commit: [#8034] send project_menu_updated events
Date Fri, 08 Jan 2016 19:30:44 GMT
[#8034] send project_menu_updated events


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

Branch: refs/heads/master
Commit: a3a344cee105e3bc7dcd972b8fef0533c357e9db
Parents: 2a78e69
Author: Dave Brondsema <dave@brondsema.net>
Authored: Thu Dec 17 14:21:31 2015 -0500
Committer: Dave Brondsema <dave@brondsema.net>
Committed: Fri Jan 8 14:06:18 2016 -0500

----------------------------------------------------------------------
 Allura/allura/app.py                              |  1 +
 Allura/allura/ext/admin/admin_main.py             | 12 +++++++++---
 Allura/allura/tests/functional/test_admin.py      |  7 +++++++
 ForgeWiki/forgewiki/tests/functional/test_root.py |  4 ++++
 4 files changed, 21 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/a3a344ce/Allura/allura/app.py
----------------------------------------------------------------------
diff --git a/Allura/allura/app.py b/Allura/allura/app.py
index 5ae34e1..fbe44be 100644
--- a/Allura/allura/app.py
+++ b/Allura/allura/app.py
@@ -880,6 +880,7 @@ class DefaultAdminController(BaseController, AdminControllerMixin):
         """
         require_access(self.app, 'configure')
         self.app.config.options['mount_label'] = mount_label
+        g.post_event('project_menu_updated')
         redirect(request.referer)
 
     @expose('jinja:allura:templates/app_admin_options.html')

http://git-wip-us.apache.org/repos/asf/allura/blob/a3a344ce/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 68863ab..32513b6 100644
--- a/Allura/allura/ext/admin/admin_main.py
+++ b/Allura/allura/ext/admin/admin_main.py
@@ -291,6 +291,7 @@ class ProjectAdminController(BaseController):
                 raise ValueError('Invalid threshold')
             c.project.set_tool_data(
                 'allura', grouping_threshold=grouping_threshold)
+            g.post_event('project_menu_updated')
         except ValueError:
             flash('Invalid threshold', 'error')
         redirect('tools?limit=%s&page=%s' % (limit, page))
@@ -648,8 +649,8 @@ class ProjectAdminController(BaseController):
                 p.ordinal = int(sp['ordinal'])
         if tools:
             for p in tools:
-                c.project.app_config(
-                    p['mount_point']).options.ordinal = int(p['ordinal'])
+                c.project.app_config(p['mount_point']).options.ordinal = int(p['ordinal'])
+        g.post_event('project_menu_updated')
         redirect('tools')
 
     def _update_mounts(self, subproject=None, tool=None, new=None, **kw):
@@ -657,6 +658,7 @@ class ProjectAdminController(BaseController):
             subproject = []
         if tool is None:
             tool = []
+        new_app = None
         for sp in subproject:
             p = M.Project.query.get(shortname=sp['shortname'],
                                     neighborhood_id=c.project.neighborhood_id)
@@ -718,13 +720,15 @@ class ProjectAdminController(BaseController):
                     k: v for (k, v) in kw.iteritems()
                     if k in [o.name for o in App.options_on_install()]
                 }
-                return c.project.install_app(
+                new_app = c.project.install_app(
                     ep_name,
                     mount_point,
                     mount_label=new['mount_label'],
                     ordinal=int(new['ordinal']) if 'ordinal' in new else None,
                     **config_on_install)
         g.post_event('project_updated')
+        g.post_event('project_menu_updated')
+        return new_app
 
     @h.vardec
     @expose()
@@ -791,6 +795,7 @@ class ProjectAdminRestController(BaseController):
                 if p:
                     p.ordinal = int(ordinal)
         M.AuditLog.log('Updated tool order')
+        g.post_event('project_menu_updated')
         return {'status': 'ok'}
 
     @expose('json:')
@@ -806,6 +811,7 @@ class ProjectAdminRestController(BaseController):
             raise exc.HTTPBadRequest('Invalid threshold. Expected a value between 1 and 10')
 
         M.AuditLog.log('Updated tool grouping threshold')
+        g.post_event('project_menu_updated')
         return {'status': 'ok'}
 
     @expose('json:')

http://git-wip-us.apache.org/repos/asf/allura/blob/a3a344ce/Allura/allura/tests/functional/test_admin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_admin.py b/Allura/allura/tests/functional/test_admin.py
index 1592f0b..4604c8c 100644
--- a/Allura/allura/tests/functional/test_admin.py
+++ b/Allura/allura/tests/functional/test_admin.py
@@ -161,6 +161,13 @@ class TestProjectAdmin(TestController):
         r = self.app.get('/admin/audit/')
         assert "uninstall tool test-tool" in r.body, r.body
 
+        # Make sure several 'project_menu_updated' events got sent
+        menu_updated_events = M.MonQTask.query.find({
+            'task_name': 'allura.tasks.event_tasks.event',
+            'args': 'project_menu_updated'
+        }).all()
+        assert_equals(len(menu_updated_events), 7)
+
     def test_features(self):
         proj = M.Project.query.get(shortname='test')
         assert_equals(proj.features, [])

http://git-wip-us.apache.org/repos/asf/allura/blob/a3a344ce/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 1afcfd3..ffda744 100644
--- a/ForgeWiki/forgewiki/tests/functional/test_root.py
+++ b/ForgeWiki/forgewiki/tests/functional/test_root.py
@@ -608,6 +608,10 @@ class TestRootController(TestController):
         assert r.form['mount_label'].value == 'Wiki'
         r = self.app.post('/admin/wiki/update_label', params=dict(
             mount_label='Tricky Wiki'))
+        assert M.MonQTask.query.find({
+            'task_name': 'allura.tasks.event_tasks.event',
+            'args': 'project_menu_updated'
+        }).all()
         r = self.app.get('/admin/wiki/edit_label', validate_chunk=True)
         assert r.form['mount_label'].value == 'Tricky Wiki'
 


Mime
View raw message