From 043f1be25d4e0478a7a775c478a7f78bd8a5bd60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Ku=C5=BE=C3=ADlek?= Date: Sun, 2 Feb 2020 01:29:30 +0100 Subject: [PATCH] OwO Pagineeeshon --- yadc/__init__.py | 1 + yadc/bp/main.py | 4 +--- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/yadc/__init__.py b/yadc/__init__.py index 4f6af4a..928fa6d 100644 --- a/yadc/__init__.py +++ b/yadc/__init__.py @@ -27,6 +27,7 @@ def create_app(): POST_LIST_THUMB_HEIGHT=200, POST_UPLOADS=os.path.join(app.instance_path, 'post'), INSTANCE_NAME='YADC', + POSTS_PER_PAGE=8, SQLALCHEMY_ECHO=True, ) diff --git a/yadc/bp/main.py b/yadc/bp/main.py index c1b8d67..c839d04 100644 --- a/yadc/bp/main.py +++ b/yadc/bp/main.py @@ -59,15 +59,13 @@ def posts(page): # page = int(args.get('page') or 1) return (tags, matched_ratings) - posts_on_page = 1 - f_tags, f_rating = parse_args() posts_query = Post.query 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.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) flash(parse_args())