def all(page=1): session_author = session.get('author', '') pastes = Paste.get_all().limit(10).offset(10 * (page - 1)).all() if not pastes and page != 1: abort(404) ## TODO handle pagination return render_template( "all.html", session_author=session_author, pastes=pastes, user=session['user'], )
def author(author, page=1): session_author = session.get('author', '') pastes = Paste.get_all(author).limit(10).offset(10 * (page - 1)).all() if not pastes and page != 1: abort(404) ## weed out private pastes if the user ## of the paste does not match the session user for paste in pastes: if not paste.user == session['user'] and paste.private: pastes.remove(paste) ## TODO handle pagination return render_template( "all.html", author=author, session_author=session_author, pastes=pastes, user=session['user'], )