Beispiel #1
0
def ratings_create_quick(film_id):
    form = FilmRatingForm(request.form)
    r = Rating(form.score.data)

    r.user_id = current_user.id
    r.film_id = film_id

    db.session().add(r)
    db.session().commit()
    return redirect(url_for("films_show", film_id=film_id))
Beispiel #2
0
def update_wishlist(movie_id):
    rating = Rating.query.filter_by(movie_id=movie_id,
                                    user_id=current_user.id).first()

    if not rating:
        rating = Rating()
        rating.movie_id = movie_id
        rating.user_id = current_user.id
        db.session().add(rating)

    if request.form.get("wishlist"):
        rating.want_to_watch = True
    else:
        rating.want_to_watch = False

    db.session().commit()

    return redirect(url_for("movies_view", movie_id=movie_id))
Beispiel #3
0
def movie_set_rating(movie_id):
    form = MovieRatingForm(request.form)

    s = Rating.check_if_user_has_rated_movie(current_user.id, movie_id)
    if not s:
        print("empty")
        u = current_user.id
        r = Rating(form.rating.data)
        r.account_id = current_user.id
        r.movie_id = movie_id
        db.session.add(r)
        db.session().commit()
    else:
        r = Rating.query.get(s[0])
        r.rating = form.rating.data
        db.session().commit()
    print(s)

    return redirect(url_for("movies_get_movie", movie_id=movie_id))
Beispiel #4
0
def ratings_create(route_id):
    form = RatingForm(request.form)
    if form.validate():
        rating = Rating.query.filter_by(account_id=current_user.id).filter_by(
            route_id=route_id).first()

        if rating is None:
            rating = Rating(int(form.new_rating.data), int(route_id))
            rating.account_id = current_user.id
            rating.set_rater_data(current_user.height, current_user.weight,
                                  current_user.arm_span)
            db.session().add(rating)
        else:
            rating._set_rating_value(int(form.new_rating.data))
            rating.set_rater_data(current_user.height, current_user.weight,
                                  current_user.arm_span)

        db.session().commit()

    return redirect(url_for("routes_index"))
Beispiel #5
0
def ratings_create():
    form = RatingForm(request.form)
    form.beer.choices = [(g.id, g.name) for g in Beer.query.all()]
    form.flavor.choices = [(g.id, g.name) for g in Flavor.query.all()]

    if not form.validate():
        return render_template("ratings/new.html", form=form)

    r = Rating(form.rating.data, form.comment.data)
    r.account_id = current_user.id
    r.beer_id = form.beer.data

    db.session().add(r)
    db.session().commit()

    for g in form.flavor.data:
        rf = RatingFlavor(r.id, g)
        db.session().add(rf)
        db.session().commit()

    return redirect(url_for("ratings_index"))
Beispiel #6
0
def ratings_create():
    form = ReviewForm(request.form)
    r = Rating(form.score.data)

    r.user_id = current_user.id
    r.film_id = form.film.data
    r.title = form.title.data
    r.review = form.review.data
    if not form.validate() or form.film.data == None:
        ratings = Rating.query.all()
        films = Film.query.all()
        for r in ratings:
            if (r.user_id == current_user.id):
                for f in films:
                    if f.id == r.film_id:
                        films.remove(f)

        form.film.choices = [(f.id, f.name) for f in films]
        return render_template("ratings/new.html", form=form)
    db.session().add(r)
    db.session().commit()
    return redirect(url_for("reviews_index"))
Beispiel #7
0
def add_rating(movie_id):
    rating = Rating.query.filter_by(movie_id=movie_id,
                                    user_id=current_user.id).first()

    form = RatingForm(request.form)
    if not form.validate():
        return render_template("movies/view.html",
                               movie=Movie.query.get(movie_id),
                               form=form,
                               rating=rating)

    if not rating:
        rating = Rating()
        rating.movie_id = movie_id
        rating.user_id = current_user.id
        rating.want_to_watch = False
        db.session().add(rating)

    rating.rating = form.rating.data

    db.session().commit()

    return redirect(url_for("movies_view", movie_id=movie_id))