1
1
Fork 0

OwO Pagineeeshon

dev
Jan Kužílek 5 years ago
parent 4d4b3d2d07
commit 043f1be25d

@ -27,6 +27,7 @@ def create_app():
POST_LIST_THUMB_HEIGHT=200, POST_LIST_THUMB_HEIGHT=200,
POST_UPLOADS=os.path.join(app.instance_path, 'post'), POST_UPLOADS=os.path.join(app.instance_path, 'post'),
INSTANCE_NAME='YADC', INSTANCE_NAME='YADC',
POSTS_PER_PAGE=8,
SQLALCHEMY_ECHO=True, SQLALCHEMY_ECHO=True,
) )

@ -59,15 +59,13 @@ def posts(page):
# page = int(args.get('page') or 1) # page = int(args.get('page') or 1)
return (tags, matched_ratings) return (tags, matched_ratings)
posts_on_page = 1
f_tags, f_rating = parse_args() f_tags, f_rating = parse_args()
posts_query = Post.query posts_query = Post.query
if len(f_tags)>0: if len(f_tags)>0:
posts_query = posts_query.join(Post.tags).group_by(Post.id).filter(Tag.content.in_(f_tags)).having(func.count(Post.id)==len(f_tags)) posts_query = posts_query.join(Post.tags).group_by(Post.id).filter(Tag.content.in_(f_tags)).having(func.count(Post.id)==len(f_tags))
posts_query = posts_query.filter(Post.rating.in_(f_rating)).order_by(Post.created) #.offset((page-1)*posts_on_page).limit(posts_on_page) posts_query = posts_query.filter(Post.rating.in_(f_rating)).order_by(Post.created) #.offset((page-1)*posts_on_page).limit(posts_on_page)
posts = posts_query.paginate(page, posts_on_page) posts = posts_query.paginate(page, app.config.get('POSTS_PER_PAGE'))
tags = tags_prepare(posts.items) tags = tags_prepare(posts.items)
flash(parse_args()) flash(parse_args())

Loading…
Cancel
Save