incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject git commit: [#6661] Fixed mismatch between REST API and bulk export for discussion
Date Mon, 23 Sep 2013 21:44:43 GMT
Updated Branches:
  refs/heads/cj/6661 [created] 9202d8e19


[#6661] Fixed mismatch between REST API and bulk export for discussion

Signed-off-by: Cory Johns <cjohns@slashdotmedia.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/9202d8e1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/9202d8e1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/9202d8e1

Branch: refs/heads/cj/6661
Commit: 9202d8e1995b0c5915493166d1a31b56fe89c1ff
Parents: f236c14
Author: Cory Johns <cjohns@slashdotmedia.com>
Authored: Mon Sep 23 21:44:25 2013 +0000
Committer: Cory Johns <cjohns@slashdotmedia.com>
Committed: Mon Sep 23 21:44:25 2013 +0000

----------------------------------------------------------------------
 Allura/allura/model/discuss.py                      |  6 ++----
 ForgeDiscussion/forgediscussion/controllers/root.py | 16 +++++++---------
 .../forgediscussion/tests/functional/test_rest.py   |  3 ++-
 3 files changed, 11 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/9202d8e1/Allura/allura/model/discuss.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/discuss.py b/Allura/allura/model/discuss.py
index 6df982f..7f17063 100644
--- a/Allura/allura/model/discuss.py
+++ b/Allura/allura/model/discuss.py
@@ -159,7 +159,7 @@ class Thread(Artifact, ActivityObject):
     first_post = RelationProperty('Post', via='first_post_id')
     ref = RelationProperty('ArtifactReference')
 
-    def __json__(self):
+    def __json__(self, limit=None, page=None):
         return dict(
             _id=self._id,
             discussion_id=str(self.discussion_id),
@@ -171,9 +171,7 @@ class Thread(Artifact, ActivityObject):
                         timestamp=p.timestamp,
                         attachments=[dict(bytes=attach.length,
                                           url=h.absurl(attach.url())) for attach in p.attachments])
-                   for p in self.post_class().query.find(
-                       dict(discussion_id=self.discussion_id, thread_id=self._id, status='ok')
-                   )
+                   for p in self.query_posts(status='ok', style='chronological', limit=limit,
page=page)
                 ]
         )
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/9202d8e1/ForgeDiscussion/forgediscussion/controllers/root.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/controllers/root.py b/ForgeDiscussion/forgediscussion/controllers/root.py
index aa1130e..ff74d63 100644
--- a/ForgeDiscussion/forgediscussion/controllers/root.py
+++ b/ForgeDiscussion/forgediscussion/controllers/root.py
@@ -23,7 +23,7 @@ import calendar
 from collections import OrderedDict
 
 
-from tg import expose, validate, redirect, flash, response
+from tg import expose, validate, redirect, flash, response, jsonify
 from tg.decorators import with_trailing_slash, without_trailing_slash
 from pylons import tmpl_context as c, app_globals as g
 from pylons import request
@@ -416,11 +416,9 @@ 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='', status='ok')
-        json = {}
-        json['topic'] = self.topic.__json__()
-        json['count'] = posts.count()
-        json['page'] = page
-        json['limit'] = limit
-        json['topic']['posts'] = posts.all()
-        return json
+        json_data = {}
+        json_data['topic'] = self.topic.__json__(limit=limit, page=page)
+        json_data['count'] = self.topic.query_posts(status='ok').count()
+        json_data['page'] = page
+        json_data['limit'] = limit
+        return json_data

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/9202d8e1/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 d9f0c39..d78a7fb 100644
--- a/ForgeDiscussion/forgediscussion/tests/functional/test_rest.py
+++ b/ForgeDiscussion/forgediscussion/tests/functional/test_rest.py
@@ -17,7 +17,7 @@
 #       specific language governing permissions and limitations
 #       under the License.
 
-from nose.tools import assert_equal
+from nose.tools import assert_equal, assert_in
 
 from allura.lib import helpers as h
 from allura.tests import decorators as td
@@ -134,6 +134,7 @@ class TestRootRestController(TestDiscussionApiBase):
         assert_equal(topic['subject'], 'Hi guys')
         assert_equal(topic['posts'][0]['text'], 'Hi boys and girls')
         assert_equal(topic['posts'][0]['subject'], 'Hi guys')
+        assert_in('timestamp', topic['posts'][0])
 
     def test_forum_list_pagination(self):
         resp = self.app.get('/rest/p/test/discussion/?limit=1')


Mime
View raw message