From 1e7f1434b062a81b46cd434bd30c309b7252c057 Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Mon, 29 May 2017 00:33:51 +0200 Subject: added some fitlters for the bookmarks page --- src/web/views/bookmark.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'src/web/views') diff --git a/src/web/views/bookmark.py b/src/web/views/bookmark.py index 9263b49f..841d7364 100644 --- a/src/web/views/bookmark.py +++ b/src/web/views/bookmark.py @@ -49,15 +49,29 @@ bookmark_bp = Blueprint('bookmark', __name__, url_prefix='/bookmark') @bookmarks_bp.route('/', defaults={'per_page': '50'}, methods=['GET']) -def list_(per_page): +@bookmarks_bp.route('/', defaults={'per_page': '50'}, + methods=['GET']) +def list_(per_page, status='all'): "Lists the bookmarks." head_titles = [gettext("Bookmarks")] if current_user.is_authenticated: # query for the bookmarks of the authenticated user - bookmark_query = BookmarkController(current_user.id).read() + filters = {} + if status == 'public': + filters['shared'] = True + elif status == 'private': + filters['shared'] = False + else: + # no filter + pass + if status == 'unread': + filters['to_read'] = True + else: + pass + bookmark_query = BookmarkController(current_user.id).read(**filters) else: - # shared bookmarks of all users + # query for the shared bookmarks (of all users) bookmark_query = BookmarkController().read(**{'shared': True}) bookmarks = bookmark_query.order_by(desc('time')) -- cgit