diff options
Diffstat (limited to 'apioforum/user.py')
-rw-r--r-- | apioforum/user.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/apioforum/user.py b/apioforum/user.py index 1a884aa..d6fbb60 100644 --- a/apioforum/user.py +++ b/apioforum/user.py @@ -24,10 +24,15 @@ def view_user(username, page=1): abort(404) posts = db.execute(""" SELECT * FROM posts - WHERE author = ? AND deleted = 0 + JOIN public_posts ON public_posts.id = posts.id + WHERE author = ? AND deleted = 0 AND public_posts.public ORDER BY created DESC LIMIT ? OFFSET ?;""",(username,POSTS_PER_PAGE,(page-1)*POSTS_PER_PAGE,)).fetchall() - num_posts = db.execute("SELECT count(*) as count FROM posts WHERE author = ?;",(username,)).fetchone()['count'] + num_posts = db.execute(""" + SELECT count(*) as count FROM posts + JOIN public_posts ON public_posts.id = posts.id + WHERE author = ? AND public_posts.public; + """,(username,)).fetchone()['count'] max_pageno = math.ceil(num_posts/POSTS_PER_PAGE) return render_template( "view_user.html", @@ -73,4 +78,4 @@ def edit_user(username): else: return redirect(url_for("user.view_user",username=username)) - return render_template("user_settings.html",user=user)
\ No newline at end of file + return render_template("user_settings.html",user=user) |