You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by tv...@apache.org on 2014/01/14 15:50:00 UTC

git commit: [#6947] Skip activity creation for meta comments

Updated Branches:
  refs/heads/tv/6947 [created] 0d6b76d09


[#6947] Skip activity creation for meta comments

Signed-off-by: Tim Van Steenburgh <tv...@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/0d6b76d0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/0d6b76d0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/0d6b76d0

Branch: refs/heads/tv/6947
Commit: 0d6b76d0986e851ae265862ba20a4d5564bcdfc4
Parents: f824160
Author: Tim Van Steenburgh <tv...@gmail.com>
Authored: Tue Jan 14 14:49:42 2014 +0000
Committer: Tim Van Steenburgh <tv...@gmail.com>
Committed: Tue Jan 14 14:49:42 2014 +0000

----------------------------------------------------------------------
 Allura/allura/model/discuss.py                       |  9 ++++++---
 .../forgetracker/tests/functional/test_root.py       | 15 +++++++++++----
 ForgeTracker/forgetracker/tracker_main.py            |  2 +-
 3 files changed, 18 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/0d6b76d0/Allura/allura/model/discuss.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/discuss.py b/Allura/allura/model/discuss.py
index 884f736..9d27470 100644
--- a/Allura/allura/model/discuss.py
+++ b/Allura/allura/model/discuss.py
@@ -255,7 +255,7 @@ class Thread(Artifact, ActivityObject):
             return g.spam_checker.check(post.text, artifact=post, user=c.user)
 
     def post(self, text, message_id=None, parent_id=None,
-             timestamp=None, ignore_security=False, **kw):
+             timestamp=None, ignore_security=False, is_meta=False, **kw):
         if not ignore_security:
             require_access(self, 'post')
         if self.ref_id and self.artifact:
@@ -271,7 +271,8 @@ class Thread(Artifact, ActivityObject):
             thread_id=self._id,
             parent_id=parent_id,
             text=text,
-            status='pending')
+            status='pending',
+            is_meta=is_meta)
         if timestamp is not None:
             kwargs['timestamp'] = timestamp
         if message_id is not None:
@@ -462,6 +463,8 @@ class Post(Message, VersionedArtifact, ActivityObject):
     edit_count = FieldProperty(int, if_missing=0)
     spam_check_id = FieldProperty(str, if_missing='')
     text_cache = FieldProperty(MarkdownCache)
+    # meta comment - system generated, describes changes to an artifact
+    is_meta = FieldProperty(bool, if_missing=False)
 
     thread = RelationProperty(Thread)
     discussion = RelationProperty(Discussion)
@@ -673,7 +676,7 @@ class Post(Message, VersionedArtifact, ActivityObject):
         self.thread.update_stats()
         if hasattr(artifact, 'update_stats'):
             artifact.update_stats()
-        if self.text:
+        if self.text and not self.is_meta:
             g.director.create_activity(author, 'posted', self, target=artifact,
                                        related_nodes=[self.app_config.project])
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/0d6b76d0/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 8860b3b..d6ec7e0 100644
--- a/ForgeTracker/forgetracker/tests/functional/test_root.py
+++ b/ForgeTracker/forgetracker/tests/functional/test_root.py
@@ -281,10 +281,7 @@ class TestFunctionalController(TrackerTestController):
             'summary': 'my ticket',
             'description': 'new description',
         })
-        # create_activity is called twice here:
-        #   - once for the ticket modification
-        #   - once for the auto-comment that's created for the ticket diff
-        assert create_activity.call_count == 2
+        assert create_activity.call_count == 1
         assert create_activity.call_args[0][1] == 'modified'
 
     def test_new_ticket(self):
@@ -672,6 +669,16 @@ class TestFunctionalController(TrackerTestController):
         assert '<span class="gd">-2</span>' in r, r.showbrowser()
         assert '<span class="gi">+4</span>' in r, r.showbrowser()
 
+    def test_meta_comment(self):
+        self.new_ticket(summary="foo")
+        self.app.post('/bugs/1/update_ticket', {
+            'summary': 'bar',
+            'comment': 'user comment',
+            })
+        t = tm.Ticket.query.get(ticket_num=1)
+        assert_true(t.discussion_thread.first_post.is_meta)
+        assert_false(t.discussion_thread.last_post.is_meta)
+
     def test_ticket_label_unlabel(self):
         summary = 'test labeling and unlabeling a ticket'
         self.new_ticket(summary=summary)

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/0d6b76d0/ForgeTracker/forgetracker/tracker_main.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tracker_main.py b/ForgeTracker/forgetracker/tracker_main.py
index cb8db76..0ae0cad 100644
--- a/ForgeTracker/forgetracker/tracker_main.py
+++ b/ForgeTracker/forgetracker/tracker_main.py
@@ -1430,7 +1430,7 @@ class TicketController(BaseController, FeedController):
         change_text = h.render_genshi_plaintext(
             tpl_fn,
             changelist=changes.get_changed())
-        post = thread.add_post(text=change_text)
+        thread.add_post(text=change_text, is_meta=True)
         self.ticket.commit()
         if comment:
             self.ticket.discussion_thread.post(text=comment)