From 4f75e30d9584566dca8f3c67a9451c22839d9da1 Mon Sep 17 00:00:00 2001 From: raven Date: Fri, 18 Jun 2021 21:38:54 +0000 Subject: recent posts --- apioforum/templates/view_user.html | 10 ++++++++++ apioforum/user.py | 8 +++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/apioforum/templates/view_user.html b/apioforum/templates/view_user.html index c9d9c1c..93618a5 100644 --- a/apioforum/templates/view_user.html +++ b/apioforum/templates/view_user.html @@ -19,4 +19,14 @@ {% endif %} +{% if posts %} +

recent posts

+
+ {% for post in posts %} + {% call disp_post(post, False) %} + {{ rendered_posts[loop.index0] | safe}} + {% endcall %} + {% endfor %} +
+{% endif %} {% endblock %} diff --git a/apioforum/user.py b/apioforum/user.py index cdf38d3..af0539a 100644 --- a/apioforum/user.py +++ b/apioforum/user.py @@ -15,5 +15,11 @@ def view_user(username): user = db.execute("SELECT * FROM users WHERE username = ?;",(username,)).fetchone() if user is None: abort(404) + posts = db.execute( + "SELECT * FROM posts WHERE author = ? ORDER BY created DESC LIMIT 25;",(username,)).fetchall() + rendered_posts = [render(post['content']) for post in posts] return render_template("view_user.html", - user=user, rendered_bio=render(user['bio'] or "hail GEORGE")) + user=user, + rendered_bio=render(user['bio'] or "hail GEORGE"), + posts=posts, + rendered_posts=rendered_posts) -- cgit v1.2.3