Add more obvious edit buttons for reviews

This commit is contained in:
rubenwardy 2020-07-10 19:01:58 +01:00
parent 491f9ed679
commit 1989eabf86
5 changed files with 26 additions and 11 deletions

@ -659,6 +659,10 @@ class Package(db.Model):
return url_for("packages.remove_self_maintainers", return url_for("packages.remove_self_maintainers",
author=self.author.username, name=self.name) author=self.author.username, name=self.name)
def getReviewURL(self):
return url_for('packages.review',
author=self.author.username, name=self.name)
def getDownloadRelease(self, version=None): def getDownloadRelease(self, version=None):
for rel in self.releases: for rel in self.releases:
if rel.approved and (version is None or if rel.approved and (version is None or

@ -53,7 +53,7 @@
<h2 class="my-3">{{ _("Recent Positive Reviews") }}</h2> <h2 class="my-3">{{ _("Recent Positive Reviews") }}</h2>
{% from "macros/reviews.html" import render_reviews %} {% from "macros/reviews.html" import render_reviews %}
{{ render_reviews(reviews, True) }} {{ render_reviews(reviews, current_user, True) }}
<div class="text-center mt-5"> <div class="text-center mt-5">
<small> <small>

@ -1,4 +1,4 @@
{% macro render_reviews(reviews, show_package_link=False) -%} {% macro render_reviews(reviews, current_user, show_package_link=False) -%}
<ul class="comments mt-4 mb-0"> <ul class="comments mt-4 mb-0">
{% for review in reviews %} {% for review in reviews %}
<li class="row my-2 mx-0"> <li class="row my-2 mx-0">
@ -31,6 +31,13 @@
</div> </div>
<div class="card-body"> <div class="card-body">
{% if current_user == review.author %}
<a class="btn btn-primary btn-sm ml-1 float-right"
href="{{ review.package.getReviewURL() }}">
<i class="fas fa-edit"></i>
</a>
{% endif %}
<p> <p>
<strong>{{ review.thread.title }}</strong> <strong>{{ review.thread.title }}</strong>
</p> </p>
@ -64,7 +71,7 @@
<div class="card-header"> <div class="card-header">
{{ _("Review") }} {{ _("Review") }}
</div> </div>
<form method="post" action="{{ url_for('packages.review', author=package.author.username, name=package.name) }}" class="card-body"> <form method="post" action="{{ package.getReviewURL() }}" class="card-body">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" /> <input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
<p> <p>
{{ _("Do you recommend this %(type)s?", type=package.type.value | lower) }} {{ _("Do you recommend this %(type)s?", type=package.type.value | lower) }}
@ -108,14 +115,12 @@
{{ _("Do you recommend this %(type)s?", type=package.type.value | lower) }} {{ _("Do you recommend this %(type)s?", type=package.type.value | lower) }}
</p> </p>
{% set review_url = url_for('packages.review', author=package.author.username, name=package.name) %}
<div class="btn-group"> <div class="btn-group">
<a class="btn btn-primary" href="{{ url_for('user.login', r=review_url) }}"> <a class="btn btn-primary" href="{{ url_for('user.login', r=package.getReviewURL()) }}">
<i class="fas fa-thumbs-up mr-2"></i> <i class="fas fa-thumbs-up mr-2"></i>
{{ _("Yes") }} {{ _("Yes") }}
</a> </a>
<a class="btn btn-primary" href="{{ url_for('user.login', r=review_url) }}"> <a class="btn btn-primary" href="{{ url_for('user.login', r=package.getReviewURL()) }}">
<i class="fas fa-thumbs-down mr-2"></i> <i class="fas fa-thumbs-down mr-2"></i>
{{ _("No") }} {{ _("No") }}
</a> </a>

@ -465,9 +465,7 @@
{% if current_user.is_authenticated %} {% if current_user.is_authenticated %}
{% if has_review %} {% if has_review %}
<p> <p>
<a <a class="btn btn-primary" href="{{ package.getReviewURL() }}">
class="btn btn-primary"
href="{{ url_for('packages.review', author=package.author.username, name=package.name) }}">
{{ _("Edit Review") }} {{ _("Edit Review") }}
</a> </a>
</p> </p>
@ -477,7 +475,7 @@
{% else %} {% else %}
{{ render_review_preview(package) }} {{ render_review_preview(package) }}
{% endif %} {% endif %}
{{ render_reviews(package.reviews) }} {{ render_reviews(package.reviews, current_user) }}
{# {#
{% if current_user.is_authenticated or requests %} {% if current_user.is_authenticated or requests %}

@ -19,6 +19,14 @@ Threads
{% endif %} {% endif %}
{% endif %} {% endif %}
{% if current_user == thread.author and thread.review %}
<a class="btn btn-primary ml-1 float-right mr-2"
href="{{ thread.review.package.getReviewURL() }}">
<i class="fas fa-edit"></i>
{{ _("Edit Review") }}
</a>
{% endif %}
<h1> <h1>
{% if thread.review %} {% if thread.review %}
{% if thread.review.recommends %} {% if thread.review.recommends %}