Show "Edit Review" button when a user already has a review
This commit is contained in:
parent
ac7adde4b1
commit
893507691b
|
@ -158,12 +158,13 @@ def view(package):
|
||||||
elif not current_user.rank.atLeast(UserRank.EDITOR) and not current_user == package.author:
|
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))
|
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", \
|
return render_template("packages/view.html", \
|
||||||
package=package, releases=releases, requests=requests, \
|
package=package, releases=releases, requests=requests, \
|
||||||
alternatives=alternatives, similar_topics=similar_topics, \
|
alternatives=alternatives, similar_topics=similar_topics, \
|
||||||
review_thread=review_thread, topic_error=topic_error, topic_error_lvl=topic_error_lvl, \
|
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/")
|
@bp.route("/packages/<author>/<name>/download/")
|
||||||
|
|
|
@ -463,7 +463,17 @@
|
||||||
|
|
||||||
{% from "macros/reviews.html" import render_reviews, render_review_form, render_review_preview %}
|
{% from "macros/reviews.html" import render_reviews, render_review_form, render_review_preview %}
|
||||||
{% if current_user.is_authenticated %}
|
{% 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 %}
|
{% else %}
|
||||||
{{ render_review_preview(package) }}
|
{{ render_review_preview(package) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
Loading…
Reference in New Issue