incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [04/26] git commit: [#6963] Disable import activities; create post-import activity
Date Wed, 22 Jan 2014 20:56:56 GMT
[#6963] Disable import activities; create post-import activity

Signed-off-by: Tim Van Steenburgh <tvansteenburgh@gmail.com>


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 <tvansteenburgh@gmail.com>
Authored: Tue Jan 14 01:48:49 2014 +0000
Committer: Cory Johns <cjohns@slashdotmedia.com>
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 <allura.app.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',


Mime
View raw message