скрыл отображение неопубликованных
parent
d8f8b36469
commit
3b63421f5f
|
@ -6,6 +6,7 @@ def get_paginated_posts(page, per_page):
|
||||||
all_post_query = (
|
all_post_query = (
|
||||||
db.session.query(Post, User)
|
db.session.query(Post, User)
|
||||||
.join(User, Post.author == User.id)
|
.join(User, Post.author == User.id)
|
||||||
|
.filter(Post.published.is_(True))
|
||||||
.order_by(Post.create_datetime.desc())
|
.order_by(Post.create_datetime.desc())
|
||||||
.paginate(page=page, per_page=per_page, error_out=True)
|
.paginate(page=page, per_page=per_page, error_out=True)
|
||||||
)
|
)
|
||||||
|
@ -16,6 +17,7 @@ def get_post(slug):
|
||||||
post_query = (
|
post_query = (
|
||||||
db.session.query(Post, User)
|
db.session.query(Post, User)
|
||||||
.join(User, Post.author == User.id)
|
.join(User, Post.author == User.id)
|
||||||
|
.filter(Post.published.is_(True))
|
||||||
.filter(Post.slug == slug)
|
.filter(Post.slug == slug)
|
||||||
.first()
|
.first()
|
||||||
)
|
)
|
||||||
|
@ -31,6 +33,7 @@ def get_all_posts_by_tag(tag, page, per_page):
|
||||||
posts_query = (
|
posts_query = (
|
||||||
db.session.query(Post, User)
|
db.session.query(Post, User)
|
||||||
.join(User, Post.author == User.id)
|
.join(User, Post.author == User.id)
|
||||||
|
.filter(Post.published.is_(True))
|
||||||
.filter(Post.tags.any(Tag.tag == tag))
|
.filter(Post.tags.any(Tag.tag == tag))
|
||||||
.order_by(Post.create_datetime.desc())
|
.order_by(Post.create_datetime.desc())
|
||||||
.paginate(page=page, per_page=per_page, error_out=True)
|
.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):
|
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
|
return page_query
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue