diff --git a/app/main/views.py b/app/main/views.py index ee19408..bced0bc 100644 --- a/app/main/views.py +++ b/app/main/views.py @@ -23,7 +23,8 @@ def index(): @main.route('/user/') def user(username): user = User.query.filter_by(username=username).first_or_404() - return render_template('user.html', user=user) + posts = user.posts.order_by(Post.timestamp.desc()).all() + return render_template('user.html', user=user, posts=posts) @main.route('/edit-profile', methods=['GET', 'POST']) diff --git a/app/templates/_posts.html b/app/templates/_posts.html new file mode 100644 index 0000000..1ca06a5 --- /dev/null +++ b/app/templates/_posts.html @@ -0,0 +1,16 @@ + diff --git a/app/templates/index.html b/app/templates/index.html index 8bc2301..4f86cca 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -14,20 +14,6 @@ {{ wtf.quick_form(form) }} {% endif %} - + +{% include '_posts.html' %} {% endblock %} diff --git a/app/templates/user.html b/app/templates/user.html index cee0191..c3b301f 100644 --- a/app/templates/user.html +++ b/app/templates/user.html @@ -26,6 +26,7 @@

Member since {{ moment(user.member_since).format('L') }}. Last seen {{ moment(user.last_seen).fromNow() }}. +

{{ user.posts.count() }} blog posts.

{% if user == current_user %} @@ -37,4 +38,6 @@

+

Posts by {{ user.username }}

+ {% include '_posts.html' %} {% endblock %}