def display_book(bid): with easypg.cursor() as cur: if flask.ext.login.current_user.is_authenticated(): book_info = books.get_book(cur, bid, flask.ext.login.current_user.id) else: book_info = books.get_book(cur, bid) # print book_info if "next" in flask.request.args: next = flask.request.args["next"] else: next = flask.url_for("home_index") return flask.render_template("book.html", book_info=book_info, next=next)
def display_book(bid): with easypg.cursor() as cur: if flask.ext.login.current_user.is_authenticated(): book_info = books.get_book(cur, bid, flask.ext.login.current_user.id) else: book_info = books.get_book(cur, bid) # print book_info if 'next' in flask.request.args: next = flask.request.args['next'] else: next = flask.url_for("home_index") return flask.render_template("book.html", book_info=book_info, next=next)
def add_review(bid): errors = [] if flask.request.method == "POST": app.logger.info( "Received new data for review from user_id %s: %s", flask.ext.login.current_user.id, flask.request.form ) with easypg.cursor() as cur: entry_status, messages, review_id = reviews.add_review( cur, bid, flask.ext.login.current_user.id, flask.request.form ) app.logger.info("Review submitted %s - %s - %s", entry_status, messages, review_id) if entry_status: for message in messages: flask.flash(message) return flask.redirect(flask.request.args.get("next") or flask.url_for("display_review", rid=review_id)) else: for message in messages: errors.append(message) with easypg.cursor() as cur: book_info = books.get_book(cur, bid, flask.ext.login.current_user.id) # print book_info['user_rating'] if "next" in flask.request.args: next = flask.request.args["next"] else: next = flask.url_for("reviews_index") return flask.render_template("review_add_form.html", book_info=book_info, error=errors, next=next)
def add_review(bid): errors = [] if flask.request.method == 'POST': app.logger.info('Received new data for review from user_id %s: %s', flask.ext.login.current_user.id, flask.request.form) with easypg.cursor() as cur: entry_status, messages, review_id = reviews.add_review( cur, bid, flask.ext.login.current_user.id, flask.request.form) app.logger.info("Review submitted %s - %s - %s", entry_status, messages, review_id) if entry_status: for message in messages: flask.flash(message) return flask.redirect( flask.request.args.get("next") or flask.url_for("display_review", rid=review_id)) else: for message in messages: errors.append(message) with easypg.cursor() as cur: book_info = books.get_book(cur, bid, flask.ext.login.current_user.id) # print book_info['user_rating'] if 'next' in flask.request.args: next = flask.request.args['next'] else: next = flask.url_for("reviews_index") return flask.render_template("review_add_form.html", book_info=book_info, error=errors, next=next)
def edit_book(bid): errors = [] if flask.request.method == 'POST': with easypg.cursor() as cur: edit_status, messages = books.edit_book(cur, bid, flask.request.form) if edit_status: for message in messages: flask.flash(message) return flask.redirect( flask.request.args.get("next") or flask.url_for("display_book", bid=bid)) else: for message in messages: errors.append(message) if 'next' in flask.request.args: next = flask.request.args['next'] else: next = flask.url_for("display_book", bid=bid) with easypg.cursor() as cur: book_info = books.get_book(cur, bid) return flask.render_template("book_edit_form.html", book_info=book_info, error=errors, next=next)
def display_book(bid): with easypg.cursor() as cur: book_info = books.get_book(cur,bid) print book_info if 'next' in flask.request.args: next = flask.request.args['next'] else: next = flask.url_for("home_index") return flask.render_template("book.html", book_info=book_info, next=next)
def add_review(bid): errors = [] if flask.request.method == 'POST': raise NotImplementedError with easypg.cursor() as cur: book_info = books.get_book(cur,bid) if 'next' in flask.request.args: next = flask.request.args['next'] else: next = flask.url_for("home_index") return flask.render_template("review_add_form.html", book_info = book_info, next=next)
def edit_book(bid): errors = [] if flask.request.method == "POST": with easypg.cursor() as cur: edit_status, messages = books.edit_book(cur, bid, flask.request.form) if edit_status: for message in messages: flask.flash(message) return flask.redirect(flask.request.args.get("next") or flask.url_for("display_book", bid=bid)) else: for message in messages: errors.append(message) if "next" in flask.request.args: next = flask.request.args["next"] else: next = flask.url_for("display_book", bid=bid) with easypg.cursor() as cur: book_info = books.get_book(cur, bid) return flask.render_template("book_edit_form.html", book_info=book_info, error=errors, next=next)