allura
Revision | c827c21dc5d9852827a88bdaf6f9115793610286 (tree) |
---|---|
Zeit | 2012-07-12 16:51:34 |
Autor | Igor Bondarenko <jetmind2@gmai...> |
Commiter | Igor Bondarenko |
[#4525] ticket:113 Fix pagination.
Show pagination on Blog discussions.
Fix Forum default pagination limit.
@@ -272,16 +272,21 @@ class PostController(BaseController): | ||
272 | 272 | |
273 | 273 | @expose('jinja:forgeblog:templates/blog/post.html') |
274 | 274 | @with_trailing_slash |
275 | - def index(self, **kw): | |
275 | + @validate(dict(page=validators.Int(if_empty=0), | |
276 | + limit=validators.Int(if_empty=25))) | |
277 | + def index(self, page=0, limit=25, **kw): | |
276 | 278 | if self.post.state == 'draft': |
277 | 279 | require_access(self.post, 'write') |
278 | 280 | c.form = W.view_post_form |
279 | 281 | c.subscribe_form = W.subscribe_form |
280 | 282 | c.thread = W.thread |
283 | + post_count = self.post.discussion_thread.post_count | |
284 | + limit, page = h.paging_sanitizer(limit, page, post_count) | |
281 | 285 | version = kw.pop('version', None) |
282 | 286 | post = self._get_version(version) |
283 | 287 | base_post = self.post |
284 | - return dict(post=post, base_post=base_post) | |
288 | + return dict(post=post, base_post=base_post, | |
289 | + page=page, limit=limit, count=post_count) | |
285 | 290 | |
286 | 291 | @expose('jinja:forgeblog:templates/blog/edit_post.html') |
287 | 292 | @without_trailing_slash |
@@ -18,7 +18,7 @@ | ||
18 | 18 | <div style="clear:both;"></div> |
19 | 19 | {% if post.discussion_thread and c.app.show_discussion %} |
20 | 20 | <div style="margin-top: 10px"> |
21 | - {{c.thread.display(value=post.discussion_thread)}} | |
21 | + {{c.thread.display(value=post.discussion_thread,page=page,limit=limit,count=count)}} | |
22 | 22 | </div> |
23 | 23 | {% endif %} |
24 | 24 | {% endblock %} |
@@ -2,9 +2,10 @@ import logging | ||
2 | 2 | import pymongo |
3 | 3 | |
4 | 4 | from tg import expose, validate, redirect |
5 | -from tg import request, response | |
5 | +from tg import request | |
6 | 6 | from pylons import g, c |
7 | 7 | from webob import exc |
8 | +from formencode import validators | |
8 | 9 | |
9 | 10 | from allura.lib import helpers as h |
10 | 11 | from allura.lib import utils |
@@ -75,7 +76,9 @@ class ForumController(DiscussionController): | ||
75 | 76 | raise exc.HTTPNotFound() |
76 | 77 | |
77 | 78 | @expose('jinja:allura:templates/discussion/index.html') |
78 | - def index(self, threads=None, limit=None, page=0, count=0, **kw): | |
79 | + @validate(dict(page=validators.Int(if_empty=0), | |
80 | + limit=validators.Int(if_empty=25))) | |
81 | + def index(self, threads=None, limit=10, page=0, count=0, **kw): | |
79 | 82 | if self.discussion.deleted: |
80 | 83 | redirect(self.discussion.url()+'deleted') |
81 | 84 | limit, page, start = g.handle_paging(limit, page) |
@@ -105,7 +108,9 @@ class ForumController(DiscussionController): | ||
105 | 108 | class ForumThreadController(ThreadController): |
106 | 109 | |
107 | 110 | @expose('jinja:forgediscussion:templates/discussionforums/thread.html') |
108 | - def index(self, limit=None, page=0, count=0, **kw): | |
111 | + @validate(dict(page=validators.Int(if_empty=0), | |
112 | + limit=validators.Int(if_empty=25))) | |
113 | + def index(self, limit=25, page=0, count=0, **kw): | |
109 | 114 | if self.thread.discussion.deleted and not has_access(c.app, 'configure')(): |
110 | 115 | redirect(self.thread.discussion.url()+'deleted') |
111 | 116 | return super(ForumThreadController, self).index(limit=limit, page=page, count=count, show_moderate=True, **kw) |