allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jetm...@apache.org
Subject [3/6] allura git commit: [#7794] ticket:677 Add handle_paging calls where only sanitizer is used
Date Fri, 14 Nov 2014 11:55:51 GMT
[#7794] ticket:677 Add handle_paging calls where only sanitizer is used


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/04b39fd9
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/04b39fd9
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/04b39fd9

Branch: refs/heads/ib/7794
Commit: 04b39fd903f89f6adf0a53d4de1e6b2224d379f8
Parents: d277d21
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Fri Nov 14 08:26:51 2014 +0000
Committer: Igor Bondarenko <jetmind2@gmail.com>
Committed: Fri Nov 14 08:57:43 2014 +0000

----------------------------------------------------------------------
 ForgeBlog/forgeblog/main.py               | 11 +++++++----
 ForgeTracker/forgetracker/tracker_main.py |  5 +++--
 ForgeWiki/forgewiki/wiki_main.py          |  7 ++++---
 3 files changed, 14 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/04b39fd9/ForgeBlog/forgeblog/main.py
----------------------------------------------------------------------
diff --git a/ForgeBlog/forgeblog/main.py b/ForgeBlog/forgeblog/main.py
index 9e70769..1e3f604 100644
--- a/ForgeBlog/forgeblog/main.py
+++ b/ForgeBlog/forgeblog/main.py
@@ -25,6 +25,7 @@ import pymongo
 from tg import config, expose, validate, redirect, flash, jsonify
 from tg.decorators import with_trailing_slash, without_trailing_slash
 from pylons import tmpl_context as c
+from pylons import app_globals as g
 from pylons import request
 from paste.deploy.converters import asbool
 import formencode
@@ -213,13 +214,14 @@ class RootController(BaseController, FeedController):
     @expose('jinja:forgeblog:templates/blog/index.html')
     @with_trailing_slash
     @validate(dict(page=validators.Int(if_empty=0, if_invalid=0),
-                   limit=validators.Int(if_empty=25, if_invalid=25)))
-    def index(self, page=0, limit=10, **kw):
+                   limit=validators.Int(if_empty=None, if_invalid=None)))
+    def index(self, page=0, limit=None, **kw):
         query_filter = dict(app_config_id=c.app.config._id)
         if not has_access(c.app, 'write')():
             query_filter['state'] = 'published'
         q = BM.BlogPost.query.find(query_filter)
         post_count = q.count()
+        limit, page, _ = g.handle_paging(limit, page)
         limit, page = h.paging_sanitizer(limit, page, post_count)
         posts = q.sort('timestamp', pymongo.DESCENDING) \
                  .skip(page * limit).limit(limit)
@@ -295,14 +297,15 @@ class PostController(BaseController, FeedController):
     @expose('jinja:forgeblog:templates/blog/post.html')
     @with_trailing_slash
     @validate(dict(page=validators.Int(if_empty=0, if_invalid=0),
-                   limit=validators.Int(if_empty=25, if_invalid=25)))
-    def index(self, page=0, limit=25, **kw):
+                   limit=validators.Int(if_empty=None, if_invalid=None)))
+    def index(self, page=0, limit=None, **kw):
         if self.post.state == 'draft':
             require_access(self.post, 'write')
         c.form = W.view_post_form
         c.subscribe_form = W.subscribe_form
         c.thread = W.thread
         post_count = self.post.discussion_thread.post_count
+        limit, page, _ = g.handle_paging(limit, page)
         limit, page = h.paging_sanitizer(limit, page, post_count)
         version = kw.pop('version', None)
         post = self._get_version(version)

http://git-wip-us.apache.org/repos/asf/allura/blob/04b39fd9/ForgeTracker/forgetracker/tracker_main.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tracker_main.py b/ForgeTracker/forgetracker/tracker_main.py
index d37b5b1..78cb678 100644
--- a/ForgeTracker/forgetracker/tracker_main.py
+++ b/ForgeTracker/forgetracker/tracker_main.py
@@ -1287,8 +1287,8 @@ class TicketController(BaseController, FeedController):
     @expose('jinja:forgetracker:templates/tracker/ticket.html')
     @validate(dict(
         page=validators.Int(if_empty=0, if_invalid=0),
-        limit=validators.Int(if_empty=10, if_invalid=10)))
-    def index(self, page=0, limit=10, deleted=False, **kw):
+        limit=validators.Int(if_empty=None, if_invalid=None)))
+    def index(self, page=0, limit=None, deleted=False, **kw):
         ticket_visible = self.ticket and not self.ticket.deleted
         if ticket_visible or has_access(self.ticket, 'delete'):
             c.ticket_form = W.ticket_form
@@ -1303,6 +1303,7 @@ class TicketController(BaseController, FeedController):
             else:
                 subscribed = M.Mailbox.subscribed(artifact=self.ticket)
             post_count = self.ticket.discussion_thread.post_count
+            limit, page, _ = g.handle_paging(limit, page)
             limit, page = h.paging_sanitizer(limit, page, post_count)
             voting_enabled = self.ticket.app.config.options.get('EnableVoting')
             return dict(ticket=self.ticket, globals=c.app.globals,

http://git-wip-us.apache.org/repos/asf/allura/blob/04b39fd9/ForgeWiki/forgewiki/wiki_main.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/wiki_main.py b/ForgeWiki/forgewiki/wiki_main.py
index 8539409..3341377 100644
--- a/ForgeWiki/forgewiki/wiki_main.py
+++ b/ForgeWiki/forgewiki/wiki_main.py
@@ -504,8 +504,8 @@ class PageController(BaseController, FeedController):
     @expose('jinja:forgewiki:templates/wiki/page_view.html')
     @validate(dict(version=validators.Int(if_empty=None, if_invalid=None),
                    page=validators.Int(if_empty=0, if_invalid=0),
-                   limit=validators.Int(if_empty=25, if_invalid=25)))
-    def index(self, version=None, page=0, limit=25, **kw):
+                   limit=validators.Int(if_empty=None, if_invalid=None)))
+    def index(self, version=None, page=0, limit=None, **kw):
         if not self.page:
             redirect(c.app.url + h.urlquote(self.title) + '/edit')
         c.confirmation = W.confirmation
@@ -513,7 +513,8 @@ class PageController(BaseController, FeedController):
         c.attachment_list = W.attachment_list
         c.subscribe_form = W.page_subscribe_form
         post_count = self.page.discussion_thread.post_count
-        limit, pagenum = h.paging_sanitizer(limit, page, post_count)
+        limit, pagenum, _ = g.handle_paging(limit, page)
+        limit, pagenum = h.paging_sanitizer(limit, pagenum, post_count)
         page = self.get_version(version)
         if page is None:
             if version:


Mime
View raw message