diff options
-rw-r--r-- | apioforum/templates/view_user.html | 10 | ||||
-rw-r--r-- | apioforum/user.py | 8 |
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) |