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 4076810D1A for ; Wed, 22 Jan 2014 20:57:10 +0000 (UTC) Received: (qmail 56431 invoked by uid 500); 22 Jan 2014 20:57:01 -0000 Delivered-To: apmail-incubator-allura-commits-archive@incubator.apache.org Received: (qmail 55972 invoked by uid 500); 22 Jan 2014 20:56:55 -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 55926 invoked by uid 99); 22 Jan 2014 20:56:54 -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, 22 Jan 2014 20:56:53 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 5C70D8A0893; Wed, 22 Jan 2014 20:56:53 +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 Date: Wed, 22 Jan 2014 20:56:56 -0000 Message-Id: <2e35400ede0f41fab8aee06d5dbfb9fb@git.apache.org> In-Reply-To: <94c643a0c4384b3db7d4529eb88a1231@git.apache.org> References: <94c643a0c4384b3db7d4529eb88a1231@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [04/26] git commit: [#6963] Disable import activities; create post-import activity [#6963] Disable import activities; create post-import activity Signed-off-by: Tim Van Steenburgh Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/ae5437a4 Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/ae5437a4 Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/ae5437a4 Branch: refs/heads/db/7062 Commit: ae5437a4a6413a473c1abdfaa5ac6bf32455cc5b Parents: 45d4fc0 Author: Tim Van Steenburgh Authored: Tue Jan 14 01:48:49 2014 +0000 Committer: Cory Johns Committed: Thu Jan 16 17:50:38 2014 +0000 ---------------------------------------------------------------------- Allura/allura/lib/helpers.py | 4 ++-- Allura/allura/model/project.py | 6 +++++- Allura/allura/model/timeline.py | 5 +++++ ForgeImporters/forgeimporters/base.py | 3 +++ ForgeImporters/forgeimporters/tests/test_base.py | 3 +++ 5 files changed, 18 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ae5437a4/Allura/allura/lib/helpers.py ---------------------------------------------------------------------- diff --git a/Allura/allura/lib/helpers.py b/Allura/allura/lib/helpers.py index ca1d386..4f84813 100644 --- a/Allura/allura/lib/helpers.py +++ b/Allura/allura/lib/helpers.py @@ -972,13 +972,13 @@ def split_select_field_options(field_options): @contextmanager -def notifications_disabled(project): +def notifications_disabled(project, disabled=True): """Temporarily disable email notifications on a project. """ orig = project.notifications_disabled try: - project.notifications_disabled = True + project.notifications_disabled = disabled yield finally: project.notifications_disabled = orig http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ae5437a4/Allura/allura/model/project.py ---------------------------------------------------------------------- diff --git a/Allura/allura/model/project.py b/Allura/allura/model/project.py index 6d40cd8..9b2024c 100644 --- a/Allura/allura/model/project.py +++ b/Allura/allura/model/project.py @@ -961,7 +961,7 @@ class Project(MappedClass, ActivityNode, ActivityObject): ) -class AppConfig(MappedClass): +class AppConfig(MappedClass, ActivityObject): """ Configuration information for an instantiated :class:`Application ` @@ -992,6 +992,10 @@ class AppConfig(MappedClass): acl = FieldProperty(ACL()) + @property + def activity_name(self): + return self.options.mount_label + def get_tool_data(self, tool, key, default=None): return self.tool_data.get(tool, {}).get(key, default) http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ae5437a4/Allura/allura/model/timeline.py ---------------------------------------------------------------------- diff --git a/Allura/allura/model/timeline.py b/Allura/allura/model/timeline.py index 7b350aa..be538a2 100644 --- a/Allura/allura/model/timeline.py +++ b/Allura/allura/model/timeline.py @@ -17,7 +17,9 @@ import bson import logging + from ming.odm import Mapper +from pylons import tmpl_context as c from activitystream import ActivityDirector from activitystream.base import NodeBase, ActivityObjectBase @@ -38,6 +40,9 @@ class Director(ActivityDirector): def create_activity(self, actor, verb, obj, target=None, related_nodes=None): + if c.project and c.project.notifications_disabled: + return + from allura.model.project import Project super(Director, self).create_activity(actor, verb, obj, target=target, related_nodes=related_nodes) http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ae5437a4/ForgeImporters/forgeimporters/base.py ---------------------------------------------------------------------- diff --git a/ForgeImporters/forgeimporters/base.py b/ForgeImporters/forgeimporters/base.py index 9be397b..9698082 100644 --- a/ForgeImporters/forgeimporters/base.py +++ b/ForgeImporters/forgeimporters/base.py @@ -127,6 +127,9 @@ def import_tool(importer_path, project_name=None, mount_point=None, mount_label= M.artifact_orm_session.flush() M.session.BatchIndexer.flush() if app: + with h.notifications_disabled(c.project, disabled=False): + g.director.create_activity(c.user, "imported", app.config, + related_nodes=[c.project]) handler.success(app) http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ae5437a4/ForgeImporters/forgeimporters/tests/test_base.py ---------------------------------------------------------------------- diff --git a/ForgeImporters/forgeimporters/tests/test_base.py b/ForgeImporters/forgeimporters/tests/test_base.py index 2156471..f7a810c 100644 --- a/ForgeImporters/forgeimporters/tests/test_base.py +++ b/ForgeImporters/forgeimporters/tests/test_base.py @@ -57,9 +57,12 @@ def test_import_tool(g, c, object_from_path): base.import_tool( 'forgeimporters.base.ToolImporter', project_name='project_name', mount_point='mount_point', mount_label='mount_label') + app = importer.return_value.import_tool.return_value importer.return_value.import_tool.assert_called_once_with(c.project, c.user, project_name='project_name', mount_point='mount_point', mount_label='mount_label') + g.director.create_activity.assert_called_once_with(c.user, "imported", + app.config, related_nodes=[c.project]) g.post_event.assert_called_once_with( 'import_tool_task_succeeded', 'source',