Example #1
0
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))
Example #3
0
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))
Example #4
0
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"))
Example #5
0
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))
Example #6
0
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))