aboutsummaryrefslogtreecommitdiff
path: root/src/web/views/bookmark.py
diff options
context:
space:
mode:
authorCédric Bonhomme <cedric@cedricbonhomme.org>2017-05-26 06:47:14 +0200
committerCédric Bonhomme <cedric@cedricbonhomme.org>2017-05-26 06:47:14 +0200
commit748a45f2e7b8de3928c0462304299c9751f729ed (patch)
tree665974a37ffc0cd12609861af59debc06da5bc3f /src/web/views/bookmark.py
parentBumped version number for Heroku. (diff)
downloadnewspipe-748a45f2e7b8de3928c0462304299c9751f729ed.tar.gz
newspipe-748a45f2e7b8de3928c0462304299c9751f729ed.tar.bz2
newspipe-748a45f2e7b8de3928c0462304299c9751f729ed.zip
added pagination for bookmarks
Diffstat (limited to 'src/web/views/bookmark.py')
-rw-r--r--src/web/views/bookmark.py20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/web/views/bookmark.py b/src/web/views/bookmark.py
index f619dc25..2f6df6bd 100644
--- a/src/web/views/bookmark.py
+++ b/src/web/views/bookmark.py
@@ -33,6 +33,7 @@ from flask import Blueprint, render_template, flash, \
redirect, request, url_for
from flask_babel import gettext
from flask_login import login_required, current_user
+from flask_paginate import Pagination, get_page_args
from sqlalchemy import desc
import conf
@@ -47,16 +48,25 @@ bookmarks_bp = Blueprint('bookmarks', __name__, url_prefix='/bookmarks')
bookmark_bp = Blueprint('bookmark', __name__, url_prefix='/bookmark')
-@bookmarks_bp.route('/', methods=['GET'])
+@bookmarks_bp.route('/', defaults={'per_page': '50'}, methods=['GET'])
@login_required
-def list():
+def list(per_page):
"Lists the bookmarks."
head_titles = ["Bookmarks"]
+
+ page, per_page, offset = get_page_args()
bookmark_contr = BookmarkController(current_user.id)
+ bookmarks = bookmark_contr.read().order_by(desc('time'))
+
+ pagination = Pagination(page=page, total=bookmarks.count(),
+ css_framework='bootstrap3',
+ search=False, record_name='bookmarks',
+ per_page=per_page)
+
return render_template('bookmarks.html',
- head_titles=head_titles,
- bookmarks=BookmarkController(current_user.id) \
- .read().order_by(desc('time')))
+ head_titles=head_titles,
+ bookmarks=bookmarks.offset(offset).limit(per_page),
+ pagination=pagination)
@bookmark_bp.route('/create', methods=['GET'])
bgstack15