Adding better pagination for wrong/right key pages

selenium-screenshot-testing
CodeKevin 2016-02-06 13:59:20 -05:00
parent 46413ba6ae
commit 0c9a4f0283
3 changed files with 16 additions and 4 deletions

View File

@ -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/<page>', 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/<teamid>', methods=['GET'])

View File

@ -60,9 +60,15 @@
{% if pages > 1 %}
<div class="text-center">Page
<br>
{% if curr_page != 1 %}<a href="/admin/correct_keys/{{ curr_page-1 }}">&lt;&lt;&lt;</a>{% endif %}
{% for page in range(1, pages + 1) %}
<a href="{{ page }}">{{ page }}</a>
{% if curr_page != page %}
<a href="/admin/wrong_keys/{{ page }}">{{ page }}</a>
{% else %}
<b>{{ page }}</b>
{% endif %}
{% endfor %}
{% if curr_page != pages %}<a href="/admin/correct_keys/{{ curr_page+1 }}">&gt;&gt;&gt;</a>{% endif %}
<a href="">
</div>
{% endif %}

View File

@ -67,9 +67,15 @@
{% if pages > 1 %}
<div class="text-center">Page
<br>
{% if curr_page != 1 %}<a href="/admin/wrong_keys/{{ curr_page-1 }}">&lt;&lt;&lt;</a>{% endif %}
{% for page in range(1, pages + 1) %}
<a href="{{ page }}">{{ page }}</a>
{% if curr_page != page %}
<a href="/admin/wrong_keys/{{ page }}">{{ page }}</a>
{% else %}
<b>{{ page }}</b>
{% endif %}
{% endfor %}
{% if curr_page != pages %}<a href="/admin/wrong_keys/{{ curr_page+1 }}">&gt;&gt;&gt;</a>{% endif %}
<a href="">
</div>
{% endif %}