From 1989eabf86729bcd16e226d96d5e4acacddbaae9 Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Fri, 10 Jul 2020 19:01:58 +0100 Subject: [PATCH] Add more obvious edit buttons for reviews --- app/models.py | 4 ++++ app/templates/index.html | 2 +- app/templates/macros/reviews.html | 17 +++++++++++------ app/templates/packages/view.html | 6 ++---- app/templates/threads/view.html | 8 ++++++++ 5 files changed, 26 insertions(+), 11 deletions(-) diff --git a/app/models.py b/app/models.py index f89fb6fa..2d436563 100644 --- a/app/models.py +++ b/app/models.py @@ -659,6 +659,10 @@ class Package(db.Model): return url_for("packages.remove_self_maintainers", 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): for rel in self.releases: if rel.approved and (version is None or diff --git a/app/templates/index.html b/app/templates/index.html index 10e00143..852ba0e1 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -53,7 +53,7 @@

{{ _("Recent Positive Reviews") }}

{% from "macros/reviews.html" import render_reviews %} - {{ render_reviews(reviews, True) }} + {{ render_reviews(reviews, current_user, True) }}
diff --git a/app/templates/macros/reviews.html b/app/templates/macros/reviews.html index 4dd51f5d..ad622da1 100644 --- a/app/templates/macros/reviews.html +++ b/app/templates/macros/reviews.html @@ -1,4 +1,4 @@ -{% macro render_reviews(reviews, show_package_link=False) -%} +{% macro render_reviews(reviews, current_user, show_package_link=False) -%}
    {% for review in reviews %}
  • @@ -31,6 +31,13 @@
+ {% if current_user == review.author %} + + + + {% endif %} +

{{ review.thread.title }}

@@ -64,7 +71,7 @@
{{ _("Review") }}
-
+

{{ _("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) }}

- {% set review_url = url_for('packages.review', author=package.author.username, name=package.name) %} -
- + {{ _("Yes") }} - + {{ _("No") }} diff --git a/app/templates/packages/view.html b/app/templates/packages/view.html index 550ea125..d60ef165 100644 --- a/app/templates/packages/view.html +++ b/app/templates/packages/view.html @@ -465,9 +465,7 @@ {% if current_user.is_authenticated %} {% if has_review %}

- + {{ _("Edit Review") }}

@@ -477,7 +475,7 @@ {% else %} {{ render_review_preview(package) }} {% endif %} - {{ render_reviews(package.reviews) }} + {{ render_reviews(package.reviews, current_user) }} {# {% if current_user.is_authenticated or requests %} diff --git a/app/templates/threads/view.html b/app/templates/threads/view.html index b91f866a..b10d1e1d 100644 --- a/app/templates/threads/view.html +++ b/app/templates/threads/view.html @@ -19,6 +19,14 @@ Threads {% endif %} {% endif %} + {% if current_user == thread.author and thread.review %} + + + {{ _("Edit Review") }} + + {% endif %} +

{% if thread.review %} {% if thread.review.recommends %}