Show "Edit Review" button when a user already has a review

This commit is contained in:
rubenwardy 2020-07-09 04:50:49 +01:00
parent ac7adde4b1
commit 893507691b
2 changed files with 13 additions and 2 deletions

View File

@ -158,12 +158,13 @@ def view(package):
elif not current_user.rank.atLeast(UserRank.EDITOR) and not current_user == package.author:
threads = threads.filter(or_(Thread.private == False, Thread.author == current_user))
has_review = PackageReview.query.filter_by(package=package, author=current_user).count() > 0
return render_template("packages/view.html", \
package=package, releases=releases, requests=requests, \
alternatives=alternatives, similar_topics=similar_topics, \
review_thread=review_thread, topic_error=topic_error, topic_error_lvl=topic_error_lvl, \
threads=threads.all())
threads=threads.all(), has_review=has_review)
@bp.route("/packages/<author>/<name>/download/")

View File

@ -463,7 +463,17 @@
{% from "macros/reviews.html" import render_reviews, render_review_form, render_review_preview %}
{% if current_user.is_authenticated %}
{{ render_review_form(package, current_user) }}
{% if has_review %}
<p>
<a
class="btn btn-primary"
href="{{ url_for('packages.review', author=package.author.username, name=package.name) }}">
{{ _("Edit Review") }}
</a>
</p>
{% else %}
{{ render_review_form(package, current_user) }}
{% endif %}
{% else %}
{{ render_review_preview(package) }}
{% endif %}