You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by jo...@apache.org on 2013/03/06 19:52:56 UTC

[1/5] git commit: [#5861] ticket:284 don't install tools twice

[#5861] ticket:284 don't install tools twice


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

Branch: refs/heads/cj/5854
Commit: a3a01f681fe8a7f4510329a7c72265d3db571f9e
Parents: dbc9c19
Author: Yuriy Arhipov <yu...@yandex.ru>
Authored: Mon Mar 4 04:00:47 2013 +0400
Committer: Dave Brondsema <db...@geek.net>
Committed: Wed Mar 6 15:33:19 2013 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/project.py               |    4 +-
 Allura/allura/lib/plugin.py                        |   19 ++++---
 Allura/allura/model/project.py                     |    4 +-
 .../allura/tests/functional/test_neighborhood.py   |   39 +++++++++++++++
 4 files changed, 54 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/a3a01f68/Allura/allura/controllers/project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/project.py b/Allura/allura/controllers/project.py
index 20c05d7..da9d111 100644
--- a/Allura/allura/controllers/project.py
+++ b/Allura/allura/controllers/project.py
@@ -202,8 +202,10 @@ class NeighborhoodController(object):
             c.project.short_description = project_description
         offset = c.project.next_mount_point(include_hidden=True)
         if tools and not neighborhood.project_template:
+            anchored_tools = neighborhood.get_anchored_tools()
             for i, tool in enumerate(tools):
-                c.project.install_app(tool, ordinal=i + offset)
+                if (tool not in anchored_tools.keys()) and (c.project.app_instance(tool) is None):
+                    c.project.install_app(tool, ordinal=i + offset)
         flash('Welcome to the SourceForge Project System! '
               'To get started, fill out some information about your project.')
         redirect(c.project.script_name + 'admin/overview')

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/a3a01f68/Allura/allura/lib/plugin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/plugin.py b/Allura/allura/lib/plugin.py
index 0c2aae2..3626167 100644
--- a/Allura/allura/lib/plugin.py
+++ b/Allura/allura/lib/plugin.py
@@ -487,16 +487,17 @@ class ProjectRegistrationProvider(object):
                         tool_options[k] = \
                                 string.Template(v).safe_substitute(
                                     p.__dict__.get('root_project', {}))
-                app = p.install_app(tool,
-                    mount_label=tool_config['label'],
-                    mount_point=tool_config['mount_point'],
-                    ordinal=i + offset,
+                if p.app_instance(tool) is None:
+                    app = p.install_app(tool,
+                        mount_label=tool_config['label'],
+                        mount_point=tool_config['mount_point'],
+                        ordinal=i + offset,
                     **tool_options)
-                if tool == 'wiki':
-                    from forgewiki import model as WM
-                    text = tool_config.get('home_text',
-                        '[[project_admins]]\n[[download_button]]')
-                    WM.Page.query.get(app_config_id=app.config._id).text = text
+                    if tool == 'wiki':
+                        from forgewiki import model as WM
+                        text = tool_config.get('home_text',
+                            '[[project_admins]]\n[[download_button]]')
+                        WM.Page.query.get(app_config_id=app.config._id).text = text
 
         if 'tool_order' in project_template:
             for i, tool in enumerate(project_template['tool_order']):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/a3a01f68/Allura/allura/model/project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/project.py b/Allura/allura/model/project.py
index 93f8257..f1535ed 100644
--- a/Allura/allura/model/project.py
+++ b/Allura/allura/model/project.py
@@ -392,7 +392,7 @@ class Project(MappedClass, ActivityNode, ActivityObject):
         from allura.app import SitemapEntry
         entries = []
 
-        anchored_tools =self.neighborhood.get_anchored_tools()
+        anchored_tools = self.neighborhood.get_anchored_tools()
         i = len(anchored_tools)
         new_tools = self.install_anchored_tools()
 
@@ -448,7 +448,7 @@ class Project(MappedClass, ActivityNode, ActivityObject):
         new_tools = []
         if not self.is_nbhd_project:
             for tool, label in anchored_tools.iteritems():
-                if tool not in installed_tools:
+                if (tool not in installed_tools) and (self.app_instance(tool) is None):
                     try:
                         new_tools.append(self.install_app(tool, tool, label, i))
                     except Exception:

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/a3a01f68/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 9a1738a..9c86a67 100644
--- a/Allura/allura/tests/functional/test_neighborhood.py
+++ b/Allura/allura/tests/functional/test_neighborhood.py
@@ -677,6 +677,45 @@ class TestNeighborhood(TestController):
             if name in ('', 'TestGroup1'):
                 assert name not in roles
 
+    def test_projects_anchored_tools(self):
+        r = self.app.post('/adobe/_admin/update', params=dict(name='Adobe',
+            css='',
+            homepage='# Adobe!\n[Root]',
+            project_template="""{
+                "private":true,
+                "tools":{
+                    "wiki":{
+                        "label":"Wiki",
+                        "mount_point":"wiki",
+                        "options":{
+                            "show_right_bar":false,
+                            "show_left_bar":false,
+                            "show_discussion":false,
+                            "some_url": "http://foo.com/$shortname/"
+                        },
+                        "home_text":"My home text!"
+                    },
+                    "admin":{"label":"Admin","mount_point":"admin"}
+                },
+                "tool_order":["wiki","admin"],
+
+                }""" ),
+            extra_environ=dict(username='root'))
+        neighborhood = M.Neighborhood.query.get(name='Adobe')
+        neighborhood.anchored_tools ='wiki:Wiki'
+        r = self.app.post(
+            '/adobe/register',
+            params=dict(
+                project_unixname='testtemp',
+                project_name='Test Template',
+                project_description='',
+                neighborhood='Adobe',
+                private_project='off'),
+            antispam=True,
+            extra_environ=dict(username='root'))
+        r = self.app.get('/adobe/testtemp/admin/tools')
+        assert '<a href="/adobe/testtemp/wiki/" class="ui-icon-tool-wiki">' in r
+        assert '<a href="/adobe/testtemp/admin/" class="ui-icon-tool-admin">' in r
 
     def test_name_suggest(self):
         r = self.app.get('/p/suggest_name?project_name=My+Moz')