You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by jo...@apache.org on 2013/07/08 21:28:16 UTC

[04/25] git commit: [#6056] Improved loading of discussion post by slug

[#6056] Improved loading of discussion post by slug

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

Branch: refs/heads/cj/4656
Commit: 9f0c841263e319cec004becc687b16703cb16951
Parents: fe6f4b2
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Tue Jul 2 02:02:54 2013 +0000
Committer: Tim Van Steenburgh <tv...@gmail.com>
Committed: Sun Jul 7 03:48:41 2013 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/discuss.py | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/9f0c8412/Allura/allura/controllers/discuss.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/discuss.py b/Allura/allura/controllers/discuss.py
index 4fa05c8..9ff5e6c 100644
--- a/Allura/allura/controllers/discuss.py
+++ b/Allura/allura/controllers/discuss.py
@@ -256,11 +256,12 @@ class PostController(BaseController):
 
     @LazyProperty
     def post(self):
-        result = self.M.Post.query.find(dict(slug=self._post_slug)).all()
-        for p in result:
-            if p.thread_id == self.thread._id: return p
-        if result:
-            redirect(result[0].url())
+        post = self.M.Post.query.get(slug=self._post_slug, thread_id=self.thread._id)
+        if post:
+            return post
+        post = self.M.Post.query.get(slug=self._post_slug)
+        if post:
+            return post
         else:
             redirect('..')