aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorraven <raven>2021-06-18 21:38:54 +0000
committerraven <raven>2021-06-18 21:38:54 +0000
commit4f75e30d9584566dca8f3c67a9451c22839d9da1 (patch)
tree5b898860a0f6ab786b7867e5bf6ce59e6c212be9
parent8bf3a017837dfaae0210cfd0d7a7d75ae6a1d45c (diff)
recent posts
-rw-r--r--apioforum/templates/view_user.html10
-rw-r--r--apioforum/user.py8
2 files changed, 17 insertions, 1 deletions
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 %}
</dl>
</div>
+{% if posts %}
+ <h2>recent posts</h2>
+ <div class="user_posts">
+ {% for post in posts %}
+ {% call disp_post(post, False) %}
+ {{ rendered_posts[loop.index0] | safe}}
+ {% endcall %}
+ {% endfor %}
+ </div>
+{% 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)