From 123c9d8aa16d19225da896d72c8baf00c10f72ae Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Sun, 29 Sep 2019 09:56:14 +0100 Subject: [PATCH] Show depicts labels in edit list. --- app.py | 13 ++++++++++++- templates/list_edits.html | 5 +++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/app.py b/app.py index 6a3a71c..4422852 100755 --- a/app.py +++ b/app.py @@ -486,7 +486,18 @@ def get_other(entity): @app.route("/admin/edits") def list_edits(): - return render_template('list_edits.html', edits=Edit.query) + # 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) @app.route("/next/Q") def next_page(item_id): diff --git a/templates/list_edits.html b/templates/list_edits.html index 355f0d5..43afda9 100644 --- a/templates/list_edits.html +++ b/templates/list_edits.html @@ -11,14 +11,15 @@ username painting depicts + when - {% for edit in edits %} + {% for edit in edit_list %} {{ edit.username }} {{ edit.painting_qid }} - {{ edit.depicts_qid }} + {{ depicts_items[edit.depicts_id].label }} ({{ edit.depicts_qid }}) {{ edit.timestamp }} {% endfor %}