You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by je...@apache.org on 2014/07/25 09:55:06 UTC
[03/28] git commit: [#7378] ticket:611 Don't include comments held
for moderation into feed
[#7378] ticket:611 Don't include comments held for moderation into feed
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/b6d0bc0d
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/b6d0bc0d
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/b6d0bc0d
Branch: refs/heads/je/42cc_7451
Commit: b6d0bc0d4df02024d66b81bf2da1aef2ca1f12eb
Parents: 12b1649
Author: Igor Bondarenko <je...@gmail.com>
Authored: Fri Jul 18 13:50:14 2014 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Fri Jul 18 18:49:30 2014 +0000
----------------------------------------------------------------------
Allura/allura/controllers/discuss.py | 9 ++++++---
Allura/allura/model/discuss.py | 20 ++++++++++++++------
Allura/allura/tests/functional/test_discuss.py | 18 ++++++++++++++++++
3 files changed, 38 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/b6d0bc0d/Allura/allura/controllers/discuss.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/discuss.py b/Allura/allura/controllers/discuss.py
index cd4e8a1..c7fe163 100644
--- a/Allura/allura/controllers/discuss.py
+++ b/Allura/allura/controllers/discuss.py
@@ -356,9 +356,11 @@ class PostController(BaseController):
elif kw.pop('spam', None):
self.post.spam()
elif kw.pop('approve', None):
- self.post.status = 'ok'
- g.spam_checker.submit_ham(
- self.post.text, artifact=self.post, user=c.user)
+ if self.post.status != 'ok':
+ self.post.status = 'ok'
+ g.spam_checker.submit_ham(
+ self.post.text, artifact=self.post, user=c.user)
+ self.post.thread.post_to_feed(self.post)
self.thread.update_stats()
return dict(result='success')
@@ -480,6 +482,7 @@ class ModerationController(BaseController):
posted.thread.last_post_date,
posted.mod_date)
posted.thread.num_replies += 1
+ posted.thread.post_to_feed(posted)
redirect(request.referer)
http://git-wip-us.apache.org/repos/asf/allura/blob/b6d0bc0d/Allura/allura/model/discuss.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/discuss.py b/Allura/allura/model/discuss.py
index 1f19208..22456e5 100644
--- a/Allura/allura/model/discuss.py
+++ b/Allura/allura/model/discuss.py
@@ -235,6 +235,19 @@ class Thread(Artifact, ActivityObject):
return self
return self.ref.artifact
+ def post_to_feed(self, post):
+ if self.ref and post.status == 'ok':
+ link = None
+ if self.app.tool_label.lower() == 'tickets':
+ link = post.url_paginated()
+ Feed.post(
+ self.primary(),
+ title=post.subject,
+ description=post.text,
+ link=link,
+ pubdate=post.mod_date,
+ )
+
def add_post(self, **kw):
"""Helper function to avoid code duplication."""
p = self.post(**kw)
@@ -242,12 +255,7 @@ class Thread(Artifact, ActivityObject):
self.num_replies += 1
if not self.first_post:
self.first_post_id = p._id
- link = None
- if self.app.tool_label.lower() == 'tickets':
- link = p.url_paginated()
- if self.ref:
- Feed.post(self.primary(), title=p.subject,
- description=p.text, link=link)
+ self.post_to_feed(p)
return p
def is_spam(self, post):
http://git-wip-us.apache.org/repos/asf/allura/blob/b6d0bc0d/Allura/allura/tests/functional/test_discuss.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_discuss.py b/Allura/allura/tests/functional/test_discuss.py
index ca3fcbd..31e454e 100644
--- a/Allura/allura/tests/functional/test_discuss.py
+++ b/Allura/allura/tests/functional/test_discuss.py
@@ -16,6 +16,7 @@
# under the License.
from mock import patch
+from nose.tools import assert_in, assert_not_in, assert_equal
from allura.tests import TestController
from allura import model as M
@@ -172,6 +173,23 @@ class TestDiscuss(TestController):
self.app.post(post_link + 'moderate', params=dict(delete='delete'))
assert M.Post.query.find().count() == 0
+ @patch.object(M.Thread, 'is_spam')
+ def test_feed_does_not_include_comments_held_for_moderation(self, is_spam):
+ is_spam.return_value = True
+ r = self._make_post('Post needs moderation!')
+ post_link = str(
+ r.html.find('div', {'class': 'edit_post_form reply'}).find('form')['action'])
+ post = M.Post.query.find().first()
+ assert_equal(post.status, 'pending')
+ r = self.app.get('/wiki/feed.rss')
+ assert_not_in('Post needs moderation!', r)
+
+ self.app.post(post_link + 'moderate', params=dict(approve='approve'))
+ post = M.Post.query.find().first()
+ assert_equal(post.status, 'ok')
+ r = self.app.get('/wiki/feed.rss')
+ assert_in('Post needs moderation!', r)
+
def test_post_paging(self):
home = self.app.get('/wiki/_discuss/')
thread_link = [a for a in home.html.findAll('a')