def my_bookmarks(current_user: User) -> flask.Response: page = int(flask.request.args.get("page", "1")) qb = BookmarkViewQueryBuilder(db.session, current_user, page=page) if "q" in flask.request.args: search_str = flask.request.args["q"] tquery_str = parse_search_str(search_str) log.debug('search_str, tquery_str = ("%s", "%s")', search_str, tquery_str) qb = qb.text_search(tquery_str).order_by_search_rank() page_title = search_str else: qb = qb.order_by_created() page_title = "Quarchive" if page > 1: page_title += " (page %s)" % page prev_page_exists = qb.has_previous_page() next_page_exists = qb.has_next_page() return flask.make_response( flask.render_template( "bookmarks.html", h1="My bookmarks", page_title=page_title, bookmark_views=qb.execute(), page=page, prev_page_exists=prev_page_exists, next_page_exists=next_page_exists, search_query=flask.request.args.get("q", ""), user_tags=user_tags_data_fn(db.session, current_user), ))
def view_bookmark(username: str, url_uuid: UUID) -> flask.Response: owner = get_user_or_fail(db.session, username) require_access_or_fail( BookmarkAccessObject(user_uuid=owner.user_uuid, url_uuid=url_uuid), Access.READ, ) qb = BookmarkViewQueryBuilder(db.session, owner).only_url(url_uuid) current_user = get_current_user() if current_user is not None: user_tags = user_tags_data_fn(db.session, current_user) else: user_tags = [] return flask.make_response( flask.render_template( "bookmarks.html", bookmark_views=qb.execute(), search_query=False, pagination=False, user_tags=user_tags, ))