[Oi-commits] trunk/forum - 15 / 15 + 1 != 2 (15th post is not in second page)...

Gökmen Görgen oi-svn at pardus.org.tr
Tue Sep 21 19:32:11 EEST 2010


Author: gkmngrgn
Date: Tue Sep 21 19:32:11 2010
New Revision: 3518

Modified:
   trunk/forum/models.py
Log:
15 / 15 + 1 != 2 (15th post is not in second page).

---
 models.py |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Modified: trunk/forum/models.py
=================================================================
--- trunk/forum/models.py	(original)
+++ trunk/forum/models.py	Tue Sep 21 19:32:11 2010
@@ -43,8 +43,13 @@
         """Use topic/forum.get_latest_post_url whenever you can"""
 
         posts = self.topic.post_set.all().order_by('created')
+        posts_count = posts.count()
 
-        page = posts.count() / POSTS_PER_PAGE + 1
+        if posts_count == POSTS_PER_PAGE:
+            page = 1
+
+        else:
+            page = posts.count() / POSTS_PER_PAGE + 1
 
         return '/forum/%s/%s/?page=%s#post%s' % (self.topic.forum.slug, self.topic.id, page, self.id)
 


More information about the Oi-commits mailing list