Return-Path: X-Original-To: apmail-incubator-allura-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-allura-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id EFE059D30 for ; Wed, 6 Mar 2013 16:10:04 +0000 (UTC) Received: (qmail 98426 invoked by uid 500); 6 Mar 2013 16:10:04 -0000 Delivered-To: apmail-incubator-allura-commits-archive@incubator.apache.org Received: (qmail 98380 invoked by uid 500); 6 Mar 2013 16:10:04 -0000 Mailing-List: contact allura-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: allura-dev@incubator.apache.org Delivered-To: mailing list allura-commits@incubator.apache.org Received: (qmail 98305 invoked by uid 99); 6 Mar 2013 16:10:02 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 06 Mar 2013 16:10:02 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 506308309C4; Wed, 6 Mar 2013 16:10:02 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: brondsem@apache.org To: allura-commits@incubator.apache.org X-Mailer: ASF-Git Admin Mailer Subject: [1/3] git commit: [#5861] ticket:284 don't install tools twice Message-Id: <20130306161002.506308309C4@tyr.zones.apache.org> Date: Wed, 6 Mar 2013 16:10:02 +0000 (UTC) [#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/master Commit: a3a01f681fe8a7f4510329a7c72265d3db571f9e Parents: dbc9c19 Author: Yuriy Arhipov Authored: Mon Mar 4 04:00:47 2013 +0400 Committer: Dave Brondsema 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 '' in r + assert '' in r def test_name_suggest(self): r = self.app.get('/p/suggest_name?project_name=My+Moz')