Improve edit list.

This commit is contained in:
Edward Betts 2019-09-29 11:14:05 +01:00
parent ad39d8d1d5
commit 7547e6fbd4
2 changed files with 6 additions and 14 deletions

12
app.py
View file

@ -495,18 +495,8 @@ def get_other(entity):
@app.route("/admin/edits")
def list_edits():
# edit_count = Edit.query.count()
edit_list = Edit.query.order_by(Edit.timestamp)
depicts_ids = {edit.depicts_id for edit in Edit.query}
q = DepictsItem.query.filter(DepictsItem.item_id.in_(depicts_ids))
depicts_items = {item.item_id: item for item in q}
return render_template('list_edits.html',
edits=Edit.query,
depicts_items=depicts_items,
edit_list=edit_list)
return render_template('list_edits.html', edits=Edit.query, edit_list=edit_list)
@app.route("/next/Q<int:item_id>")
def next_page(item_id):

View file

@ -18,9 +18,11 @@
{% for edit in edit_list %}
<tr>
<td><a href="{{ edit.user_page_url }}">{{ edit.username }}</a></td>
<td>{{ edit.painting_qid }}</td>
<td>{{ depicts_items[edit.depicts_id].label }} ({{ edit.depicts_qid }})</td>
<td>{{ edit.timestamp }}</td>
<td><a href="https://www.wikidata.org/wiki/{{ edit.painting_qid }}">{{ edit.painting.label }}</a>
({{ edit.painting_qid }})</td>
<td><a href="https://www.wikidata.org/wiki/{{ edit.depicts_qid }}">{{ edit.depicts.label }}</a>
({{ edit.depicts_qid }})</td>
<td>{{ edit.timestamp.strftime('%H:%M %a, %d %b %Y') }}</td>
</tr>
{% endfor %}
</tbody>