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))
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"))