changeset 471:17ee0418e93c

function to get the count for results per page has been modified, and minor modification(based upon previous) in global_history function
author Akash Sinha <akash2607@gmail.com>
date Fri, 24 Jun 2011 16:06:17 +0530
parents bba40d458d9e
children c04d1ca903c7
files MoinMoin/apps/frontend/views.py MoinMoin/user.py
diffstat 2 files changed, 9 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/apps/frontend/views.py	Thu Jun 23 00:15:01 2011 +0530
+++ b/MoinMoin/apps/frontend/views.py	Fri Jun 24 16:06:17 2011 +0530
@@ -548,10 +548,10 @@
 @frontend.route('/+history')
 def global_history():
     history = flaskg.storage.history(item_name='')
-    count = 0
+    results_per_page = int(app.cfg.results_per_page)
     if flaskg.user.valid:
         bookmark_time = flaskg.user.getBookmark()
-        count = flaskg.user.getCount()
+        results_per_page = flaskg.user.ResultsPerPage(results_per_page)
     else:
         bookmark_time = None
     item_groups = OrderedDict()
@@ -640,12 +640,9 @@
     # Grouping on the date basis
     offset = request.values.get('offset', 0)
     offset = int(offset)
-    if not count:
-        count = int(app.cfg.results_per_page)
-
     day_count = OrderedDict()
     revcount = 0
-    maxrev = count + offset
+    maxrev = results_per_page + offset
     toappend = True
     grouped_history = []
     prev_date = '0000-00-00'
@@ -681,12 +678,12 @@
     prev_rev_count = day_count.values()
     prev_rev_count.reverse()
     for numrev in prev_rev_count:
-        if previous_offset < count:
+        if previous_offset < results_per_page:
             previous_offset += numrev
         else:
             break
 
-    if offset - previous_offset >= count:
+    if offset - previous_offset >= results_per_page:
         previous_offset = offset - previous_offset
     elif previous_offset:
         previous_offset = 0
--- a/MoinMoin/user.py	Thu Jun 23 00:15:01 2011 +0530
+++ b/MoinMoin/user.py	Fri Jun 24 16:06:17 2011 +0530
@@ -791,17 +791,16 @@
         return mailok, msg
 
 # -----------------------------------------------------------------
-    # Result Count
-    def getCount(self):
+    # Number of results per page
+    def ResultsPerPage(self, results_per_page=0):
         """ Get count for number of history results to display per page
 
         :rtype: int
         :returns: count value or None
         """
-        count = None
         if self.valid:
             try:
-                count = self.results_per_page
+                results_per_page = self.results_per_page
             except AttributeError:
                 pass
-        return count
+        return results_per_page