]> git.ipfire.org Git - thirdparty/patchwork.git/commit
pagination: Fix quirks
authorDaniel Axtens <dja@axtens.net>
Thu, 25 Jan 2018 02:43:11 +0000 (13:43 +1100)
committerStephen Finucane <stephen@that.guru>
Fri, 26 Jan 2018 21:25:03 +0000 (21:25 +0000)
commitbd1613c1d4f915ffd76880afbf4746521f28e831
tree2ab71cdf2b7bbf181e6f6f80f0a74ca6b5c9cb4c
parentd254d1e36cd2acf830e5977920ca2ec6370fbd69
pagination: Fix quirks

There are a couple of pages where the clickable list of pages
would include missing or duplicate pages.

Write a test that ensures:
 - you always have a link to the next/prev numbered page
 - there are no duplicate page numbers

Fiddle with the pagination algorithm to get it to pass - required
tweaking a display parameter and a couple of comparison operators,
so all pretty minor.

Now, if there are 10 pages, the displayed page numbers for a given
page are as follows:

Page # | Displayed page #s
---------------------------
1      | [] [1, 2, 3, 4] [9, 10]
2      | [] [1, 2, 3, 4] [9, 10]
3      | [] [1, 2, 3, 4] [9, 10]
4      | [1, 2] [3, 4, 5] [9, 10]
5      | [1, 2] [4, 5, 6] [9, 10]
6      | [1, 2] [5, 6, 7] [9, 10]
7      | [1, 2] [6, 7, 8] [9, 10]
8      | [1, 2] [7, 8, 9, 10] []
9      | [1, 2] [7, 8, 9, 10] []
10     | [1, 2] [7, 8, 9, 10] []

Closes: #102
Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Stephen Finucane <stephen@that.guru>
patchwork/paginator.py
patchwork/tests/test_paginator.py