Commit 26a169d9 authored by Fengxu Lin's avatar Fengxu Lin Committed by 老广

fix bug in pagination_range function (#511)

start and end may be float when current_num >= 3 and display % 2 == 1
parent 4e67749e
......@@ -30,8 +30,13 @@ def pagination_range(total_page, current_num=1, display=5):
except ValueError:
current_num = 1
start = current_num - display/2 if current_num > display/2 else 1
end = start + display if start + display <= total_page else total_page + 1
half_display = int(display/2)
start = current_num - half_display if current_num > half_display else 1
if start + display <= total_page:
end = start + display
else:
end = total_page + 1
start = end - display if end > display else 1
return range(start, end)
......@@ -68,4 +73,4 @@ def to_html(s):
@register.filter
def proxy_log_commands(log_id):
return command_store.filter(proxy_log_id=log_id)
\ No newline at end of file
return command_store.filter(proxy_log_id=log_id)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment