mirror of
https://github.com/minetest/contentdb.git
synced 2024-11-12 18:43:48 +01:00
parent
86e1f57198
commit
c1edea4dc3
@ -161,15 +161,19 @@ def handle_review_vote(package: Package, review_id: int):
|
|||||||
flash("You can't vote on your own reviews!", "danger")
|
flash("You can't vote on your own reviews!", "danger")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
is_positive = isYes(request.form["is_positive"])
|
||||||
|
|
||||||
vote = PackageReviewVote.query.filter_by(review=review, user=current_user).first()
|
vote = PackageReviewVote.query.filter_by(review=review, user=current_user).first()
|
||||||
if vote is None:
|
if vote is None:
|
||||||
vote = PackageReviewVote()
|
vote = PackageReviewVote()
|
||||||
vote.review = review
|
vote.review = review
|
||||||
vote.user = current_user
|
vote.user = current_user
|
||||||
vote.is_positive = isYes(request.form["is_positive"])
|
vote.is_positive = is_positive
|
||||||
db.session.add(vote)
|
db.session.add(vote)
|
||||||
|
elif vote.is_positive == is_positive:
|
||||||
|
db.session.delete(vote)
|
||||||
else:
|
else:
|
||||||
vote.is_positive = isYes(request.form["is_positive"])
|
vote.is_positive = is_positive
|
||||||
|
|
||||||
review.update_score()
|
review.update_score()
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
Loading…
Reference in New Issue
Block a user