allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tvansteenbu...@apache.org
Subject [17/50] git commit: [#6446] ticket:400 added filtering for topics in api, test fail
Date Thu, 08 Aug 2013 13:34:36 GMT
[#6446] ticket:400 added filtering for topics in api, test fail


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

Branch: refs/heads/tv/6458
Commit: dbb1cb191586af7293303208115a83efb1e07829
Parents: 625bf2e
Author: Anton Kasyanov <mind1master@gmail.com>
Authored: Mon Jul 22 14:09:15 2013 +0300
Committer: Tim Van Steenburgh <tvansteenburgh@gmail.com>
Committed: Wed Jul 31 14:55:48 2013 +0000

----------------------------------------------------------------------
 Allura/allura/model/discuss.py                  |  4 +++-
 .../forgediscussion/controllers/root.py         |  2 +-
 .../tests/functional/test_rest.py               | 21 ++++++++++++++++++++
 3 files changed, 25 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/dbb1cb19/Allura/allura/model/discuss.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/discuss.py b/Allura/allura/model/discuss.py
index 76cf615..97d19d0 100644
--- a/Allura/allura/model/discuss.py
+++ b/Allura/allura/model/discuss.py
@@ -328,13 +328,15 @@ class Thread(Artifact, ActivityObject):
         return result
 
     def query_posts(self, page=None, limit=None,
-                    timestamp=None, style='threaded'):
+                    timestamp=None, style='threaded', status=None):
         if timestamp:
             terms = dict(discussion_id=self.discussion_id, thread_id=self._id,
                     status={'$in': ['ok', 'pending']}, timestamp=timestamp)
         else:
             terms = dict(discussion_id=self.discussion_id, thread_id=self._id,
                     status={'$in': ['ok', 'pending']})
+        if status:
+            terms['status'] = status       
         q = self.post_class().query.find(terms)
         if style == 'threaded':
             q = q.sort('full_slug')

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/dbb1cb19/ForgeDiscussion/forgediscussion/controllers/root.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/controllers/root.py b/ForgeDiscussion/forgediscussion/controllers/root.py
index 67e51ca..7dd18c7 100644
--- a/ForgeDiscussion/forgediscussion/controllers/root.py
+++ b/ForgeDiscussion/forgediscussion/controllers/root.py
@@ -334,7 +334,7 @@ class ForumTopicRestController(BaseController):
     @expose('json:')
     def index(self, limit=100, page=0, **kw):
         limit, page, start = g.handle_paging(int(limit), int(page))
-        posts = self.topic.query_posts(page=page, limit=limit, style='')
+        posts = self.topic.query_posts(page=page, limit=limit, style='', status='ok')
         json = {}
         json['topic'] = self.topic.__json__()
         json['count'] = posts.count()

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/dbb1cb19/ForgeDiscussion/forgediscussion/tests/functional/test_rest.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/tests/functional/test_rest.py b/ForgeDiscussion/forgediscussion/tests/functional/test_rest.py
index 56c01ff..7fc3499 100644
--- a/ForgeDiscussion/forgediscussion/tests/functional/test_rest.py
+++ b/ForgeDiscussion/forgediscussion/tests/functional/test_rest.py
@@ -168,6 +168,27 @@ class TestRootRestController(TestDiscussionApiBase):
         assert_equal(resp.json['page'], 1)
         assert_equal(resp.json['limit'], 1)
 
+    def test_topic_show_ok_only(self):
+        # import logging
+        # log = logging.getLogger(__name__)
+
+        thread = ForumThread.query.find({'subject': 'Hi guys'}).first()        
+        url = '/rest/p/test/discussion/general/thread/%s/' % thread._id
+        resp = self.app.get(url)
+        posts = resp.json['topic']['posts']
+        assert_equal(len(posts), 1)
+        thread.post('Hello', 'I am not ok post')
+        last_post = thread.last_post
+        last_post.status = 'pending'
+        last_post.commit()
+
+        resp = self.app.get(url)
+        posts = resp.json['topic']['posts']        
+
+        # log.info('ready to debug')
+        # log.info(posts)
+        assert_equal(len(posts), 1)
+
     def test_security(self):
         p = M.Project.query.get(shortname='test')
         acl = p.app_instance('discussion').config.acl


Mime
View raw message