X-Git-Url: http://git.veekun.com/zzz-spline-forum.git/blobdiff_plain/0e16b0d0c02d3459c55c40b1d164f26b45a7d971..eda83e616ace71957edf96a49a6e80ea3ae27b2a:/splinext/forum/controllers/forum.py?ds=sidebyside diff --git a/splinext/forum/controllers/forum.py b/splinext/forum/controllers/forum.py index 5d962e0..0d1207f 100644 --- a/splinext/forum/controllers/forum.py +++ b/splinext/forum/controllers/forum.py @@ -147,10 +147,18 @@ class ForumController(BaseController): c.write_thread_form = WriteThreadForm() - c.threads = c.forum.threads.options( - joinedload('last_post'), - joinedload('last_post.author'), - ) + # nb: This will never show post-less threads. Oh well! + threads_q = c.forum.threads \ + .join(forum_model.Thread.last_post) \ + .order_by(forum_model.Post.posted_time.desc()) \ + .options(joinedload('last_post.author')) + c.num_threads = threads_q.count() + try: + c.skip = int(request.params.get('skip', 0)) + except ValueError: + abort(404) + c.per_page = 89 + c.threads = threads_q.offset(c.skip).limit(c.per_page) return render('/forum/threads.mako') @@ -163,6 +171,17 @@ class ForumController(BaseController): c.write_post_form = WritePostForm() + posts_q = c.thread.posts \ + .order_by(forum_model.Post.position.asc()) \ + .options(joinedload('author')) + c.num_posts = c.thread.post_count + try: + c.skip = int(request.params.get('skip', 0)) + except ValueError: + abort(404) + c.per_page = 89 + c.posts = posts_q.offset(c.skip).limit(c.per_page) + return render('/forum/posts.mako')