From 8e1de4a2a39556689c93af3c7bbc149c85cbb5e5 Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Sun, 29 Sep 2019 11:52:12 +0100 Subject: [PATCH] User pages. --- app.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app.py b/app.py index 7054544..3639122 100755 --- a/app.py +++ b/app.py @@ -512,6 +512,21 @@ def list_edits(): painting_count=painting_count, user_count=user_count) +@app.route("/user/") +def user_page(username): + edit_list = Edit.query.filter_by(username=username).order_by(Edit.timestamp) + + painting_count = (database.session + .query(func.count(distinct(Edit.painting_id))) + .filter_by(username=username) + .scalar()) + + return render_template('user_page.html', + username=username, + edits=Edit.query, + edit_list=edit_list, + painting_count=painting_count) + @app.route("/next/Q") def next_page(item_id): qid = f'Q{item_id}'