]> 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 22:02:08 +0000 (22:02 +0000)
commit43575d154c95de4e0a41e1e15547383c7795fc99
treefda92013ba5a9aac149b46fb7e42a5ee2bb7fe38
parentd2631287d1fee379be41b2c11187bc3ee4c0a7f9
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>
(cherry picked from commit bd1613c1d4f915ffd76880afbf4746521f28e831)
patchwork/paginator.py
patchwork/tests/test_paginator.py