• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

allura


Commit MetaInfo

Revisionc827c21dc5d9852827a88bdaf6f9115793610286 (tree)
Zeit2012-07-12 16:51:34
AutorIgor Bondarenko <jetmind2@gmai...>
CommiterIgor Bondarenko

Log Message

[#4525] ticket:113 Fix pagination.

Show pagination on Blog discussions.
Fix Forum default pagination limit.

Ändern Zusammenfassung

Diff

--- a/ForgeBlog/forgeblog/main.py
+++ b/ForgeBlog/forgeblog/main.py
@@ -272,16 +272,21 @@ class PostController(BaseController):
272272
273273 @expose('jinja:forgeblog:templates/blog/post.html')
274274 @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):
276278 if self.post.state == 'draft':
277279 require_access(self.post, 'write')
278280 c.form = W.view_post_form
279281 c.subscribe_form = W.subscribe_form
280282 c.thread = W.thread
283+ post_count = self.post.discussion_thread.post_count
284+ limit, page = h.paging_sanitizer(limit, page, post_count)
281285 version = kw.pop('version', None)
282286 post = self._get_version(version)
283287 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)
285290
286291 @expose('jinja:forgeblog:templates/blog/edit_post.html')
287292 @without_trailing_slash
--- a/ForgeBlog/forgeblog/templates/blog/post.html
+++ b/ForgeBlog/forgeblog/templates/blog/post.html
@@ -18,7 +18,7 @@
1818 <div style="clear:both;"></div>
1919 {% if post.discussion_thread and c.app.show_discussion %}
2020 <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)}}
2222 </div>
2323 {% endif %}
2424 {% endblock %}
--- a/ForgeDiscussion/forgediscussion/controllers/forum.py
+++ b/ForgeDiscussion/forgediscussion/controllers/forum.py
@@ -2,9 +2,10 @@ import logging
22 import pymongo
33
44 from tg import expose, validate, redirect
5-from tg import request, response
5+from tg import request
66 from pylons import g, c
77 from webob import exc
8+from formencode import validators
89
910 from allura.lib import helpers as h
1011 from allura.lib import utils
@@ -75,7 +76,9 @@ class ForumController(DiscussionController):
7576 raise exc.HTTPNotFound()
7677
7778 @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):
7982 if self.discussion.deleted:
8083 redirect(self.discussion.url()+'deleted')
8184 limit, page, start = g.handle_paging(limit, page)
@@ -105,7 +108,9 @@ class ForumController(DiscussionController):
105108 class ForumThreadController(ThreadController):
106109
107110 @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):
109114 if self.thread.discussion.deleted and not has_access(c.app, 'configure')():
110115 redirect(self.thread.discussion.url()+'deleted')
111116 return super(ForumThreadController, self).index(limit=limit, page=page, count=count, show_moderate=True, **kw)