Add pager to recent changes.

This commit is contained in:
Edward Betts 2019-12-30 16:11:19 +00:00
parent f1264c8333
commit 54b94923e6
2 changed files with 14 additions and 8 deletions

8
app.py
View file

@ -503,7 +503,9 @@ def get_other(entity):
@app.route("/edits")
def list_edits():
edit_list = Edit.query.order_by(Edit.timestamp.desc())
q = Edit.query.order_by(Edit.timestamp.desc())
page = utils.get_int_arg('page') or 1
pager = Pagination(page, 100, q.count())
item_count = (database.session
.query(func.count(distinct(Edit.artwork_id)))
@ -514,8 +516,8 @@ def list_edits():
.scalar())
return render_template('list_edits.html',
edits=Edit.query,
edit_list=edit_list,
pager=pager,
edit_list=pager.slice(q),
item_count=item_count,
user_count=user_count)

View file

@ -1,15 +1,18 @@
{% from "macro.html" import render_pagination %}
{% extends "base.html" %}
{% block content %}
<div class="p-2">
<p>This tool has been used to add a total of {{ edits.count() }} depicts statements.</p>
<p>This tool has been used to add a total of {{ '{:,d}'.format(pager.total_count) }} depicts statements.</p>
<p>{{ user_count }} users have tried this tool.</p>
<p>{{ '{:,d}'.format(user_count) }} users have tried this tool.</p>
<p>{{ item_count }} artworks have been cataloged.</p>
<p>{{ '{:,d}'.format(item_count) }} artworks have been cataloged.</p>
<table class="table w-auto">
{{ render_pagination(pager) }}
<table class="table">
<thead>
<tr>
<th>username</th>
@ -28,12 +31,13 @@
</td>
<td><a href="https://www.wikidata.org/wiki/{{ edit.depicts_qid }}">{{ edit.depicts.label }}</a>
({{ edit.depicts_qid }})</td>
<td>{{ edit.timestamp.strftime('%Y %b %d %H:%M') }}</td>
<td class="text-nowrap">{{ edit.timestamp.strftime('%Y %b %d %H:%M') }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{{ render_pagination(pager) }}
</div>