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 2012/11/27 14:46:06 UTC

[19/44] git commit: [#4616] Made notifications_disabled a transient property to prevent it getting left on

[#4616] Made notifications_disabled a transient property to prevent it getting left on

Signed-off-by: Cory Johns <jo...@geek.net>


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

Branch: refs/heads/cj/4691
Commit: ee3b45133c2c93a53ff5d3b93293806e073f2ea4
Parents: 236fdb1
Author: Cory Johns <jo...@geek.net>
Authored: Wed Nov 7 20:38:48 2012 +0000
Committer: Tim Van Steenburgh <tv...@gmail.com>
Committed: Thu Nov 8 19:03:28 2012 +0000

----------------------------------------------------------------------
 Allura/allura/model/monq_model.py                  |    8 ++++++--
 Allura/allura/model/notification.py                |    4 +++-
 Allura/allura/model/project.py                     |    5 +++--
 .../forgetracker/tests/functional/test_root.py     |    5 +++--
 4 files changed, 15 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ee3b4513/Allura/allura/model/monq_model.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/monq_model.py b/Allura/allura/model/monq_model.py
index a9b2278..3a8ba3a 100644
--- a/Allura/allura/model/monq_model.py
+++ b/Allura/allura/model/monq_model.py
@@ -71,7 +71,8 @@ class MonQTask(MappedClass):
     context = FieldProperty(dict(
             project_id=S.ObjectId,
             app_config_id=S.ObjectId,
-            user_id=S.ObjectId))
+            user_id=S.ObjectId,
+            notifications_disabled=bool))
     args = FieldProperty([])
     kwargs = FieldProperty({None:None})
     result = FieldProperty(None, if_missing=None)
@@ -122,9 +123,11 @@ class MonQTask(MappedClass):
         context = dict(
             project_id=None,
             app_config_id=None,
-            user_id=None)
+            user_id=None,
+            notifications_disabled=False)
         if getattr(c, 'project', None):
             context['project_id']=c.project._id
+            context['notifications_disabled']=c.project.notifications_disabled
         if getattr(c, 'app', None):
             context['app_config_id']=c.app.config._id
         if getattr(c, 'user', None):
@@ -219,6 +222,7 @@ class MonQTask(MappedClass):
             c.project = M.Project.query.get(_id=self.context.project_id)
             c.app = None
             if c.project:
+                c.project.notifications_disabled = self.context.get('notifications_disabled', False)
                 app_config = M.AppConfig.query.get(_id=self.context.app_config_id)
                 if app_config:
                     c.app = c.project.app_instance(app_config)

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ee3b4513/Allura/allura/model/notification.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/notification.py b/Allura/allura/model/notification.py
index da98389..fe06a95 100644
--- a/Allura/allura/model/notification.py
+++ b/Allura/allura/model/notification.py
@@ -178,7 +178,9 @@ class Notification(MappedClass):
             log.warn('Could not render notification template %s' % artifact.type_s, exc_info=True)
 
         assert d['reply_to_address'] is not None
-        project = Project.query.get(_id=d.get('project_id', c.project._id))
+        project = c.project
+        if d.get('project_id', c.project._id) != c.project._id:
+            project = Project.query.get(_id=d['project_id'])
         if project.notifications_disabled:
             log.info('Notifications disabled for project %s, not sending %s(%r)',
                      project.shortname, topic, artifact)

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ee3b4513/Allura/allura/model/project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/project.py b/Allura/allura/model/project.py
index 5938be1..fc7eb00 100644
--- a/Allura/allura/model/project.py
+++ b/Allura/allura/model/project.py
@@ -122,8 +122,6 @@ class Project(MappedClass, ActivityNode, ActivityObject):
     neighborhood_id = ForeignIdProperty(Neighborhood)
     shortname = FieldProperty(str)
     name=FieldProperty(str)
-    notifications_disabled = FieldProperty(bool)
-    suppress_emails = FieldProperty(bool)
     show_download_button=FieldProperty(S.Deprecated)
     short_description=FieldProperty(str, if_missing='')
     summary=FieldProperty(str, if_missing='')
@@ -164,6 +162,9 @@ class Project(MappedClass, ActivityNode, ActivityObject):
     tracking_id = FieldProperty(str, if_missing='')
     is_nbhd_project=FieldProperty(bool, if_missing=False)
 
+    # transient properties
+    notifications_disabled = False
+
     @property
     def activity_name(self):
         return self.shortname

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ee3b4513/ForgeTracker/forgetracker/tests/functional/test_root.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tests/functional/test_root.py b/ForgeTracker/forgetracker/tests/functional/test_root.py
index 10a6479..77a0c87 100644
--- a/ForgeTracker/forgetracker/tests/functional/test_root.py
+++ b/ForgeTracker/forgetracker/tests/functional/test_root.py
@@ -1147,9 +1147,10 @@ class TestEmailMonitoring(TrackerTestController):
         """
         p = M.Project.query.get(shortname='test')
         p.notifications_disabled = True
-        ThreadLocalORMSession.flush_all()
         self._set_options()
-        self.new_ticket(summary='test')
+        with patch.object(M.Project.query, 'get') as get:
+            get.side_effect = lambda *a,**k: None if 'bugs' in k.get('shortname', '') else p
+            self.new_ticket(summary='test')
         assert send_simple.call_count == 0, send_simple.call_count
 
 class TestCustomUserField(TrackerTestController):