def vote_submit(review_id): review_id = str(review_id) if 'yes' in request.form: vote = True elif 'no' in request.form: vote = False else: vote = None review = Review.query.get_or_404(review_id) if review.is_hidden and not current_user.is_admin(): raise NotFound(gettext("Review has been hidden.")) if review.user == current_user: flash.error(gettext("You cannot rate your own review.")) return redirect(url_for('.entity', id=review_id)) if current_user.is_vote_limit_exceeded is True and current_user.has_voted( review) is False: flash.error(gettext("You have exceeded your limit of votes per day.")) return redirect(url_for('.entity', id=review_id)) if current_user.is_blocked: flash.error( gettext("You are not allowed to rate this review because " "your account has been blocked by a moderator.")) return redirect(url_for('.entity', id=review_id)) db_vote.submit( user_id=current_user.id, revision_id=review.last_revision.id, vote=vote, # overwrites an existing vote, if needed ) flash.success(gettext("You have rated this review!")) return redirect(url_for('.entity', id=review_id))
def vote_submit(review_id): review_id = str(review_id) if 'yes' in request.form: vote = True elif 'no' in request.form: vote = False review = Review.query.get_or_404(review_id) if review.is_hidden and not current_user.is_admin(): raise NotFound(gettext("Review has been hidden.")) if review.user == current_user: flash(gettext("You cannot rate your own review."), 'error') return redirect(url_for('.entity', id=review_id)) if current_user.is_vote_limit_exceeded is True and current_user.has_voted(review) is False: flash(gettext("You have exceeded your limit of votes per day."), 'error') return redirect(url_for('.entity', id=review_id)) if current_user.is_blocked: flash(gettext("You are not allowed to rate this review because " "your account has been blocked by a moderator."), 'error') return redirect(url_for('.entity', id=review_id)) Vote.create(current_user, review, vote) # overwrites an existing vote, if needed flash(gettext("You have rated this review!"), 'success') return redirect(url_for('.entity', id=review_id))
def vote_submit(review_id): review_id = str(review_id) if 'yes' in request.form: vote = True elif 'no' in request.form: vote = False review = Review.query.get_or_404(review_id) if review.is_hidden and not current_user.is_admin(): raise NotFound(gettext("Review has been hidden.")) if review.user == current_user: flash(gettext("You cannot rate your own review."), 'error') return redirect(url_for('.entity', id=review_id)) if current_user.is_vote_limit_exceeded is True and current_user.has_voted( review) is False: flash(gettext("You have exceeded your limit of votes per day."), 'error') return redirect(url_for('.entity', id=review_id)) if current_user.is_blocked: flash( gettext("You are not allowed to rate this review because " "your account has been blocked by a moderator."), 'error') return redirect(url_for('.entity', id=review_id)) if vote is True and current_user.user_type not in review.review_class.upvote: flash(gettext("You are not allowed to rate this review."), 'error') return redirect(url_for('.entity', id=review_id)) if vote is False and current_user.user_type not in review.review_class.downvote: flash(gettext("You are not allowed to rate this review."), 'error') return redirect(url_for('.entity', id=review_id)) Vote.create(current_user, review, vote) # overwrites an existing vote, if needed flash(gettext("You have rated this review!"), 'success') return redirect(url_for('.entity', id=review_id))
def logout(): current_user.has_voted() logout_user() return redirect(url_for("main.index"))