def reviews_create(): form = ReviewForm(request.form) if not form.validate(): return render_template("reviews/new.html", form=form) t = Review(form.score.data, form.comment.data) t.account_id = current_user.id db.session().add(t) db.session().commit() return redirect(url_for("reviews_index"))
def reviews_create(movie_id): form = ReviewForm(request.form) if not form.validate(): return render_template("reviews/new.html", form = form, movie = Movie.query.get(movie_id)) r = Review(form.reviewtext.data, form.rating.data) r.account_id = current_user.id r.movie_id = movie_id db.session().add(r) db.session().commit() return redirect(url_for("reviews_for_movie", movie_id = movie_id))
def reviews_modify(review_id): re = Review.get_review_by_id(review_id) if re['account_id'] != current_user.id: return login_manager.unauthorized() if request.method == "GET": form = ReviewForm(stars=re['stars']) form.author.data = re['author'] form.name.data = re['book'] form.review.data = re['review'] return render_template("reviews/modify.html", form=form, review_id=review_id) form = ReviewForm(request.form) if not form.validate(): return render_template("reviews/modify.html", form=form) r = Review.query.get(review_id) r.review = form.review.data r.stars = form.stars.data db.session().commit() return redirect(url_for("reviews_index"))
def reviews_new(book_id): if request.method == "GET": return render_template("reviews/new.html", form=ReviewForm(), book_id=book_id) user_id = current_user.id form = ReviewForm(request.form) new_review = Review(form.score.data, form.text.data) new_review.user_id = user_id new_review.book_id = book_id db.session().add(new_review) db.session().commit() return redirect(url_for("books_show", book_id=book_id))
def review_item(item_id): if request.method == "GET": return render_template("/reviews/reviewform.html", form=ReviewFormItem(), item_id=item_id) form = ReviewFormItem(request.form) if not form.validate: return render_template("/reviews/reviewform.html", form=form) r = Review(form.title.data, form.quality.data, form.comment.data) r.item_id = item_id db.session().add(r) db.session().commit() return redirect(url_for("items_index"))
def reviews_search(): if request.method == "GET": return render_template("reviews/list.html", show=1, form=SearchForm()) r = Review.find_by_author(request.form.get("author")) return render_template("reviews/list.html", show=1, reviews=r, form=SearchForm())
def review_create(recipe_id): form = ReviewForm(request.form) if not form.validate(): return redirect(url_for("recipe_view", recipe_id=recipe_id)) review = Review.query.filter_by(account_id=current_user.id, recipe_id=recipe_id).first() if not review: review = Review(form.rating.data) review.recipe_id = recipe_id review.account_id = current_user.id db.session().add(review) db.session().commit() else: review.rating = form.rating.data db.session().commit() return redirect(url_for("recipe_view", recipe_id=recipe_id))
def reviews_createOrUpdate(): if('create' in request.form): form = ReviewForm(request.form) if not form.validate(): return render_template("reviews/new.html", form = form, game = Game.query.filter_by(id=form.game_id.data).first()) game_id = form.game_id.data grade = form.grade.data text = form.text.data review = Review(game_id, grade, text) review.game_id = game_id review.user_id = current_user.id db.session().add(review) db.session().commit() elif('edit' in request.form): form = ReviewEditForm(request.form) if not form.validate(): return render_template("reviews/edit.html", form = form, game = Game.query.filter_by(id=form.game_id.data).first()) review_id = form.review_id.data review = Review.query.filter_by(id=review_id).first() review.grade = form.grade.data review.text = form.text.data db.session().commit() return redirect(url_for("reviews_index", game_id = form.game_id.data))
def reviews_create(): form = ReviewForm(request.form) given_author = form.author.data given_book = form.name.data if not form.validate(): return render_template("reviews/new.html", form=form) if db.session.query(Author).filter( Author.name == given_author).scalar() is None: a = Author(given_author) db.session.add(a) db.session.commit() if db.session.query(Book).filter( Book.book_name == given_book).scalar() is None: a = db.session.query( Author.id).filter(Author.name == given_author).scalar() b = Book(given_book, a) db.session.add(b) db.session.commit() b = db.session.query(Book.id).filter(Book.book_name == given_book).scalar() r = Review(b, form.review.data, form.stars.data) r.account_id = current_user.id db.session().add(r) if db.session.query(MustReads).filter( MustReads.book_id == b).scalar() is None: mr = MustReads(b) mr.read = True mr.account_id = current_user.id db.session().add(mr) db.session().commit() return redirect(url_for("reviews_index"))
def reviews_create(game_id): game = Game.query.get(game_id) if not game: return redirect(url_for('games_index')) form = ReviewForm(request.form) if not form.validate(): return render_template('reviews/new.html', game = game, form = form ) review = Review( form.content.data, form.rating.data ) review.game_id = game_id review.account_id = current_user.id db.session().add(review) db.session().commit() return redirect(url_for('reviews_show', game_id = game_id))
def reviews_create(): form = ReviewForm(request.form) if not form.validate(): book = Book.query.get(form.book_id.data) return render_template("reviews/new.html", form=form, book=book) newReview = Review(form.rating.data, form.reviewText.data, form.book_id.data, current_user.id) db.session().add(newReview) db.session().commit() return redirect(url_for("book_view", book_id=form.book_id.data))
def reviews_create(game_id): form = ReviewForm(request.form) game = Game.query.get(game_id) if not game: return render_template("error.html", error="PeliƤ ei ole olemassa") if request.method == "GET": return render_template("reviews/new.html", form=ReviewForm(), game=Game.query.get(game_id)) if not form.validate(): return render_template("reviews/new.html", form=form, game=game) if current_user.has_reviewed(game): return render_template("error.html", error="Et voi arvioida samaa peliƤ uudelleen") review = Review(form.text.data, form.points.data) review.game_id = game_id review.account_id = current_user.id db.session().add(review) db.session().commit() return redirect(url_for("games_view", game_id=game_id))
def make_review(self, data, **kwargs): return Review(**data)
def reviews_index(): return render_template("reviews/list.html", show=2, reviews=Review.get_review(current_user.id))
def reviews_front(): return render_template("reviews/list.html", reviews=Review.get_all_reviews(), show=3, books=Review.ranking(), users=Review.most_reviews())
def index(): return render_template("index.html", topmovies=Movie.list_movies_with_highest_scores(), latestmovies=Movie.list_latest_movie_additions(), latestreviews=Review.list_latest_reviews())
def make_object(self, data): return Review(**data)