allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [5/5] git commit: [#6056] Improved loading of discussion post by slug
Date Tue, 02 Jul 2013 02:04:00 GMT
[#6056] Improved loading of discussion post by slug

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/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 <cjohns@slashdotmedia.com>
Authored: Tue Jul 2 02:02:54 2013 +0000
Committer: Cory Johns <cjohns@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('..')
 


Mime
View raw message