Make the history view pagination prettier.

This commit is contained in:
Chase Sterling 2016-07-07 17:39:37 -04:00
parent 35471d3c3f
commit 242e317e65
2 changed files with 27 additions and 21 deletions

View file

@ -64,14 +64,14 @@ def revert():
def history(name):
if current_app.config.get('PRIVATE_WIKI') and current_user.is_anonymous():
return current_app.login_manager.unauthorized()
ITEMS_PER_PAGE = 15
items_per_page = 15
page = int(request.args.get('page', 1))
start_index = (page - 1) * ITEMS_PER_PAGE
hist = g.current_wiki.get_page(name).get_history()
start_index = (page - 1) * items_per_page
hist = g.current_wiki.get_page(name).history
# Grab one extra item to see if there is a next page
items = hist[start_index:start_index+ITEMS_PER_PAGE+1]
items = list(itertools.islice(hist, start_index, start_index+items_per_page+1))
more = False
if len(items) > ITEMS_PER_PAGE:
if len(items) > items_per_page:
more = True
items.pop()
if page > 1 and not items: