From 0c9a4f028334258d9edca8c7fcfd36d842a2ce4e Mon Sep 17 00:00:00 2001 From: CodeKevin Date: Sat, 6 Feb 2016 13:59:20 -0500 Subject: [PATCH] Adding better pagination for wrong/right key pages --- CTFd/admin.py | 4 ++-- CTFd/templates/admin/correct_keys.html | 8 +++++++- CTFd/templates/admin/wrong_keys.html | 8 +++++++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/CTFd/admin.py b/CTFd/admin.py index 504f232..51f87ba 100644 --- a/CTFd/admin.py +++ b/CTFd/admin.py @@ -546,7 +546,7 @@ def admin_wrong_key(page='1'): wrong_count = db.session.query(db.func.count(WrongKeys.id)).first()[0] pages = int(wrong_count / results_per_page) + (wrong_count % results_per_page > 0) - return render_template('admin/wrong_keys.html', wrong_keys=wrong_keys, pages=pages) + return render_template('admin/wrong_keys.html', wrong_keys=wrong_keys, pages=pages, curr_page=page) @admin.route('/admin/correct_keys/', methods=['GET']) @@ -564,7 +564,7 @@ def admin_correct_key(page='1'): solve_count = db.session.query(db.func.count(Solves.id)).first()[0] pages = int(solve_count / results_per_page) + (solve_count % results_per_page > 0) - return render_template('admin/correct_keys.html', solves=solves, pages=pages) + return render_template('admin/correct_keys.html', solves=solves, pages=pages, curr_page=page) @admin.route('/admin/fails/', methods=['GET']) diff --git a/CTFd/templates/admin/correct_keys.html b/CTFd/templates/admin/correct_keys.html index 9a5a553..212ccd3 100644 --- a/CTFd/templates/admin/correct_keys.html +++ b/CTFd/templates/admin/correct_keys.html @@ -60,9 +60,15 @@ {% if pages > 1 %}
Page
+ {% if curr_page != 1 %}<<<{% endif %} {% for page in range(1, pages + 1) %} - {{ page }} + {% if curr_page != page %} + {{ page }} + {% else %} + {{ page }} + {% endif %} {% endfor %} + {% if curr_page != pages %}>>>{% endif %}
{% endif %} diff --git a/CTFd/templates/admin/wrong_keys.html b/CTFd/templates/admin/wrong_keys.html index 46ca602..a52086d 100644 --- a/CTFd/templates/admin/wrong_keys.html +++ b/CTFd/templates/admin/wrong_keys.html @@ -67,9 +67,15 @@ {% if pages > 1 %}
Page
+ {% if curr_page != 1 %}
<<<{% endif %} {% for page in range(1, pages + 1) %} - {{ page }} + {% if curr_page != page %} + {{ page }} + {% else %} + {{ page }} + {% endif %} {% endfor %} + {% if curr_page != pages %}>>>{% endif %}
{% endif %}