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