From aafa56df953c530c56fc6006f2e57d62bfffd87f Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Fri, 15 Nov 2024 18:57:31 +0000 Subject: [PATCH] Update reviews hypertext --- app/utils/minetest_hypertext.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/utils/minetest_hypertext.py b/app/utils/minetest_hypertext.py index 3cc60510..edf51525 100644 --- a/app/utils/minetest_hypertext.py +++ b/app/utils/minetest_hypertext.py @@ -322,6 +322,9 @@ def package_reviews_as_hypertext(package: Package, formspec_version: int = 7): links[f"link_{link_counter}"] = url return f"{escape_hypertext(label)}" + body += make_link(package.get_url("packages.review", absolute=True), gettext("Leave a review")) + body += "\n\n" + reviews = package.reviews.all() for review in reviews: review: PackageReview @@ -333,8 +336,11 @@ def package_reviews_as_hypertext(package: Package, formspec_version: int = 7): author = make_link(abs_url_for("users.profile", username=review.author.username), review.author.display_name) rating = ["", "", "", "", ""][review.rating - 1] - comments = make_link(abs_url_for("threads.view", id=review.thread.id), "Comments") - body += f"{author} {rating}\n{escape_hypertext(review.thread.title)}\n{comment_body}\n{comments}\n\n" + num_comments = review.thread.replies.count() + comments = make_link(abs_url_for("threads.view", id=review.thread.id), f"Comments [{num_comments}]") + positive, negative, _ = review.get_totals() + helpful = f"{positive} helpful, {negative} unhelpful" + body += f"{author} {rating}\n{escape_hypertext(review.thread.title)}\n{comment_body}\n{comments} - {helpful}\n\n" if len(reviews) == 0: body += escape_hypertext(gettext("No reviews available."))