@@ -36,10 +36,11 @@ def _positive_int(integer_string, strict=False, cutoff=None):
36
36
37
37
def _divide_with_ceil (a , b ):
38
38
"""
39
- Returns 'a' divded by 'b', with any remainder rounded up.
39
+ Returns 'a' divided by 'b', with any remainder rounded up.
40
40
"""
41
41
if a % b :
42
42
return (a // b ) + 1
43
+
43
44
return a // b
44
45
45
46
@@ -358,17 +359,24 @@ def get_previous_link(self):
358
359
359
360
def get_html_context (self ):
360
361
base_url = self .request .build_absolute_uri ()
361
- current = _divide_with_ceil (self .offset , self .limit ) + 1
362
- # The number of pages is a little bit fiddly.
363
- # We need to sum both the number of pages from current offset to end
364
- # plus the number of pages up to the current offset.
365
- # When offset is not strictly divisible by the limit then we may
366
- # end up introducing an extra page as an artifact.
367
- final = (
368
- _divide_with_ceil (self .count - self .offset , self .limit ) +
369
- _divide_with_ceil (self .offset , self .limit )
370
- )
371
- if final < 1 :
362
+
363
+ if self .limit :
364
+ current = _divide_with_ceil (self .offset , self .limit ) + 1
365
+
366
+ # The number of pages is a little bit fiddly.
367
+ # We need to sum both the number of pages from current offset to end
368
+ # plus the number of pages up to the current offset.
369
+ # When offset is not strictly divisible by the limit then we may
370
+ # end up introducing an extra page as an artifact.
371
+ final = (
372
+ _divide_with_ceil (self .count - self .offset , self .limit ) +
373
+ _divide_with_ceil (self .offset , self .limit )
374
+ )
375
+
376
+ if final < 1 :
377
+ final = 1
378
+ else :
379
+ current = 1
372
380
final = 1
373
381
374
382
if current > final :
0 commit comments