# HG changeset patch # User Daniele Nicolodi # Date 1313272590 -7200 # Node ID 52480306b6410cf83c3476dbe6bc0d698e7906cb # Parent c3634ffa5a82ed01d2368bee0bd083b1b038650e Show only seven pagination links by default. diff -r c3634ffa5a82 -r 52480306b641 src/ltpdarepo/pagination.py --- a/src/ltpdarepo/pagination.py Sat Aug 13 23:56:23 2011 +0200 +++ b/src/ltpdarepo/pagination.py Sat Aug 13 23:56:30 2011 +0200 @@ -1,7 +1,7 @@ from math import ceil, floor class Pagination(object): - def __init__(self, page=1, count=10, size=10, items=9): + def __init__(self, page=1, count=10, size=10, items=7): self.current = page self.size = size self.count = count diff -r c3634ffa5a82 -r 52480306b641 src/ltpdarepo/tests/test_pagination.py --- a/src/ltpdarepo/tests/test_pagination.py Sat Aug 13 23:56:23 2011 +0200 +++ b/src/ltpdarepo/tests/test_pagination.py Sat Aug 13 23:56:30 2011 +0200 @@ -31,7 +31,7 @@ self.assertEqual(l, [1, 2]) def test_pages_without_ellipsis(self): - for i in range(1, 10): + for i in range(1, 8): p = Pagination(1, size*i, size) l = list(p) self.assertEqual(l, range(1, i + 1)) @@ -41,42 +41,42 @@ npages = 15 nitems = size*npages - for i in range(1, 6): + for i in range(1, 4): p = Pagination(i, nitems, size) l = list(p) - self.assertEqual(len(l), 9) - self.assertEqual(l, [1, 2, 3, 4, 5, 6, 7, -7, 15]) + self.assertEqual(len(l), 7) + self.assertEqual(l, [1, 2, 3, 4, 5, -9, 15]) p = Pagination(6, nitems, size) l = list(p) - self.assertEqual(len(l), 9) - self.assertEqual(l, [1, -2, 4, 5, 6, 7, 8, -6, 15]) + self.assertEqual(len(l), 7) + self.assertEqual(l, [1, -3, 5, 6, 7, -7, 15]) p = Pagination(7, nitems, size) l = list(p) - self.assertEqual(len(l), 9) - self.assertEqual(l, [1, -3, 5, 6, 7, 8, 9, -5, 15]) + self.assertEqual(len(l), 7) + self.assertEqual(l, [1, -4, 6, 7, 8, -6, 15]) p = Pagination(8, nitems, size) l = list(p) - self.assertEqual(len(l), 9) - self.assertEqual(l, [1, -4, 6, 7, 8, 9, 10, -4, 15]) + self.assertEqual(len(l), 7) + self.assertEqual(l, [1, -5, 7, 8, 9, -5, 15]) p = Pagination(9, nitems, size) l = list(p) - self.assertEqual(len(l), 9) - self.assertEqual(l, [1, -5, 7, 8, 9, 10, 11, -3, 15]) + self.assertEqual(len(l), 7) + self.assertEqual(l, [1, -6, 8, 9, 10, -4, 15]) p = Pagination(10, nitems, size) l = list(p) - self.assertEqual(len(l), 9) - self.assertEqual(l, [1, -6, 8, 9, 10, 11, 12, -2, 15]) + self.assertEqual(len(l), 7) + self.assertEqual(l, [1, -7, 9, 10, 11, -3, 15]) - for i in range(11, 15): + for i in range(12, 15): p = Pagination(i, nitems, size) l = list(p) - self.assertEqual(len(l), 9) - self.assertEqual(l, [1, -7, 9, 10, 11, 12, 13, 14, 15]) + self.assertEqual(len(l), 7) + self.assertEqual(l, [1, -9, 11, 12, 13, 14, 15]) if __name__ == '__main__':