allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [6/8] allura git commit: [#7981] don't allow overlapping subscriptions between Forums and its Threads
Date Fri, 18 Nov 2016 22:53:36 GMT
[#7981] don't allow overlapping subscriptions between Forums and its Threads


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

Branch: refs/heads/db/7981
Commit: 83e84d91e6e6761f3f11b1a138a69d6d25997c61
Parents: 4507559
Author: Dave Brondsema <dave@brondsema.net>
Authored: Fri Nov 18 17:52:02 2016 -0500
Committer: Dave Brondsema <dave@brondsema.net>
Committed: Fri Nov 18 17:53:18 2016 -0500

----------------------------------------------------------------------
 Allura/allura/model/artifact.py                      |  2 +-
 Allura/allura/model/notification.py                  |  3 ++-
 ForgeDiscussion/forgediscussion/controllers/forum.py | 12 ++++++++++--
 3 files changed, 13 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/83e84d91/Allura/allura/model/artifact.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/artifact.py b/Allura/allura/model/artifact.py
index 39316d2..523a7ad 100644
--- a/Allura/allura/model/artifact.py
+++ b/Allura/allura/model/artifact.py
@@ -201,7 +201,7 @@ class Artifact(MappedClass, SearchIndexable):
         from allura.model import Mailbox
         if user is None:
             user = c.user
-        Mailbox.subscribe(
+        return Mailbox.subscribe(
             user_id=user._id,
             project_id=self.app_config.project_id,
             app_config_id=self.app_config._id,

http://git-wip-us.apache.org/repos/asf/allura/blob/83e84d91/Allura/allura/model/notification.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/notification.py b/Allura/allura/model/notification.py
index 52ef451..80ff6a6 100644
--- a/Allura/allura/model/notification.py
+++ b/Allura/allura/model/notification.py
@@ -486,8 +486,9 @@ class Mailbox(MappedClass):
             # tool
             for other_mbox in cls.query.find(dict(
                     user_id=user_id, project_id=project_id, app_config_id=app_config_id)):
-                if other_mbox is not mbox:
+                if other_mbox != mbox:
                     other_mbox.delete()
+        return mbox
 
     @classmethod
     def unsubscribe(

http://git-wip-us.apache.org/repos/asf/allura/blob/83e84d91/ForgeDiscussion/forgediscussion/controllers/forum.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/controllers/forum.py b/ForgeDiscussion/forgediscussion/controllers/forum.py
index bb0fa33..a53d5f4 100644
--- a/ForgeDiscussion/forgediscussion/controllers/forum.py
+++ b/ForgeDiscussion/forgediscussion/controllers/forum.py
@@ -116,7 +116,6 @@ class ForumController(DiscussionController):
             limit=limit,
             page=page)
 
-
     @expose('jinja:forgediscussion:templates/discussionforums/deleted.html')
     def deleted(self):
         return dict()
@@ -126,7 +125,16 @@ class ForumController(DiscussionController):
     @validate(W.subscribe_form)
     def subscribe_to_forum(self, subscribe=None, unsubscribe=None, shortname=None, **kw):
         if subscribe:
-            self.discussion.subscribe(type='direct')
+            mbox = self.discussion.subscribe(type='direct')
+            # unsubscribe from all individual threads, so you don't have overlapping subscriptions
+            # TODO: run as a remove() op instead of loop?
+            for other_mbox in M.Mailbox.query.find(dict(user_id=c.user._id,
+                                                        project_id=c.project._id,
+                                                        app_config_id=c.app.config._id,
+                                                        )):
+                # TODO: check that artifact_id is not None, or a Forum, or a thread in a
different Forum
+                if other_mbox != mbox:
+                    other_mbox.delete()
         elif unsubscribe:
             self.discussion.unsubscribe()
         return {


Mime
View raw message