From 3b63421f5f04201d0d5265cab8573f68762e4031 Mon Sep 17 00:00:00 2001 From: pi3c Date: Wed, 11 Oct 2023 21:34:45 +0300 Subject: [PATCH] =?UTF-8?q?=D1=81=D0=BA=D1=80=D1=8B=D0=BB=20=D0=BE=D1=82?= =?UTF-8?q?=D0=BE=D0=B1=D1=80=D0=B0=D0=B6=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BD?= =?UTF-8?q?=D0=B5=D0=BE=D0=BF=D1=83=D0=B1=D0=BB=D0=B8=D0=BA=D0=BE=D0=B2?= =?UTF-8?q?=D0=B0=D0=BD=D0=BD=D1=8B=D1=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pyproger/dbase/database.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pyproger/dbase/database.py b/pyproger/dbase/database.py index cc7c8d9..f9848ca 100644 --- a/pyproger/dbase/database.py +++ b/pyproger/dbase/database.py @@ -6,6 +6,7 @@ def get_paginated_posts(page, per_page): all_post_query = ( db.session.query(Post, User) .join(User, Post.author == User.id) + .filter(Post.published.is_(True)) .order_by(Post.create_datetime.desc()) .paginate(page=page, per_page=per_page, error_out=True) ) @@ -16,6 +17,7 @@ def get_post(slug): post_query = ( db.session.query(Post, User) .join(User, Post.author == User.id) + .filter(Post.published.is_(True)) .filter(Post.slug == slug) .first() ) @@ -31,6 +33,7 @@ def get_all_posts_by_tag(tag, page, per_page): posts_query = ( db.session.query(Post, User) .join(User, Post.author == User.id) + .filter(Post.published.is_(True)) .filter(Post.tags.any(Tag.tag == tag)) .order_by(Post.create_datetime.desc()) .paginate(page=page, per_page=per_page, error_out=True) @@ -44,7 +47,12 @@ def get_all_posts_by_tag(tag, page, per_page): def get_page(slug): - page_query = db.session.query(Page).filter(Page.slug == slug).one_or_none() + page_query = ( + db.session.query(Page) + .filter(Post.published.is_(True)) + .filter(Page.slug == slug) + .one_or_none() + ) return page_query