Author: eallen
Date: 2008-08-22 10:18:33 -0400 (Fri, 22 Aug 2008)
New Revision: 2349
Modified:
mgmt/trunk/cumin/python/wooly/widgets.py
Log:
Fixed bug in paginator where the current page could be greater than the max number of
pages.
Fixed bug in generating next/previous pageset links where the page number was not being
updated.
Modified: mgmt/trunk/cumin/python/wooly/widgets.py
===================================================================
--- mgmt/trunk/cumin/python/wooly/widgets.py 2008-08-22 12:26:48 UTC (rev 2348)
+++ mgmt/trunk/cumin/python/wooly/widgets.py 2008-08-22 14:18:33 UTC (rev 2349)
@@ -282,6 +282,20 @@
return self.pageset_size * pageset, self.pageset_size * (pageset + 1)
def set_count(self, session, count):
+ page_index = self.page_index.get(session)
+ pageset_index = self.pageset_index.get(session)
+ count_per_pageset = self.page_size * self.pageset_size
+
+ # is the count too low to be on the current pageset
+ if count < count_per_pageset * pageset_index:
+ self.pageset_index.set(session, 0)
+ self.page_index.set(session, 0)
+
+ # is the count too low to be on the current page
+ elif count < page_index * self.page_size:
+ self.pageset_index.set(session, 0)
+ self.page_index.set(session, 0)
+
return self.page_count.set(session, count)
def get_count(self, session):
@@ -341,8 +355,10 @@
if pageset < 1:
html = self.__link(session.marshal(), "<<",
"pagenav disabled")
else:
+ page_index = self.page_index.get(session)
branch = session.branch()
self.pageset_index.set(branch, pageset - 1)
+ self.page_index.set(branch, page_index - self.pageset_size)
html = self.__link(branch.marshal(), "<<",
"pagenav")
return html
@@ -355,6 +371,11 @@
else:
branch = session.branch()
self.pageset_index.set(branch, pageset + 1)
+ new_page_index = self.page_index.get(branch) + self.pageset_size
+ max_page_count = self.get_page_count(branch)
+ if new_page_index >= max_page_count:
+ new_page_index = max_page_count - 1
+ self.page_index.set(branch, new_page_index)
html = self.__link(branch.marshal(), ">>",
"pagenav")
return html
Show replies by date