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/02 04:04:00 UTC

[5/5] 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/a27becec
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/a27becec
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/a27becec

Branch: refs/heads/cj/6056
Commit: a27bececd1bfdc8ae3141ff8cbd3c39e34fcb155
Parents: 1491096
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Tue Jul 2 02:02:54 2013 +0000
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Tue Jul 2 02:02:54 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/a27becec/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('..')