Add ability to make neutral reviews

This commit is contained in:
rubenwardy
2023-04-15 02:37:58 +01:00
parent 1235bc14db
commit b1bd39c0fc
15 changed files with 101 additions and 34 deletions

View File

@@ -69,9 +69,11 @@
<span class="btn" title="{{ _('Reviews') }}">
<i class="fas fa-star-half-alt"></i>
<span class="count">
+{{ package.reviews | selectattr("recommends") | list | length }}
+{{ package.reviews | selectattr("rating", "equalto", 5) | list | length }}
/
-{{ package.reviews | rejectattr("recommends") | list | length }}
{{ package.reviews | selectattr("rating", "equalto", 3) | list | length }}
/
-{{ package.reviews | selectattr("rating", "equalto", 1) | list | length }}
</span>
</span>
</div>

View File

@@ -31,10 +31,12 @@
</a>
</div>
<div class="col-md-auto pl-1 pr-3 pt-2 text-center" style=" font-size: 200%;">
{% if review.recommends %}
{% if review.rating > 3 %}
<i class="fas fa-thumbs-up" style="color:#6f6;"></i>
{% else %}
{% elif review.rating < 3 %}
<i class="fas fa-thumbs-down" style="color:#f66;"></i>
{% else %}
<i class="fas fa-minus" style="color:#999"></i>
{% endif %}
</div>
{% if review.thread %}
@@ -112,11 +114,15 @@
<div class="btn-group btn-group-toggle" data-toggle="buttons">
<label class="btn btn-primary">
<i class="fas fa-thumbs-up mr-2"></i>
<input type="radio" name="recommends" value="yes" autocomplete="off"> {{ _("Yes") }}
<input type="radio" name="rating" value="5" autocomplete="off"> {{ _("Yes") }}
</label>
<label class="btn btn-primary">
<i class="fas fa-minus mr-2"></i>
<input type="radio" name="rating" value="3" autocomplete="off"> {{ _("Neutral") }}
</label>
<label class="btn btn-primary">
<i class="fas fa-thumbs-down mr-2"></i>
<input type="radio" name="recommends" value="no" autocomplete="off"> {{ _("No") }}
<input type="radio" name="rating" value="1" autocomplete="off"> {{ _("No") }}
</label>
</div>
@@ -149,11 +155,15 @@
</p>
<div class="btn-group">
<button class="btn btn-primary" name="recommends" value="yes">
<button class="btn btn-primary" name="rating" value="5">
<i class="fas fa-thumbs-up mr-2"></i>
{{ _("Yes") }}
</button>
<button class="btn btn-primary" name="recommends" value="no">
<button class="btn btn-primary" name="rating" value="3">
<i class="fas fa-minus mr-2"></i>
{{ _("Neutral") }}
</button>
<button class="btn btn-primary" name="rating" value="1">
<i class="fas fa-thumbs-down mr-2"></i>
{{ _("No") }}
</button>

View File

@@ -224,10 +224,12 @@
<i class="fas fa-lock" style="color:#ffac33;"></i>
{% elif not t.review %}
<i class="fas fa-comment-alt" style="color:#666;"></i>
{% elif t.review.recommends %}
{% elif t.review.rating > 3 %}
<i class="fas fa-thumbs-up" style="color:#6f6;"></i>
{% else %}
{% elif t.review.rating < 3 %}
<i class="fas fa-thumbs-down" style="color:#f66;"></i>
{% else %}
<i class="fas fa-minus" style="color:#999"></i>
{% endif %}
<strong class="ml-1">
{{ t.title }}

View File

@@ -34,7 +34,7 @@
<p>
{{ _("Do you recommend this %(type)s?", type=package.type.text | lower) }}
</p>
{{ render_toggle_field(form.recommends, icons={"yes":"fa-thumbs-up", "no":"fa-thumbs-down"}) }}
{{ render_toggle_field(form.rating, icons={"5":"fa-thumbs-up", "3": "fa-minus", "1":"fa-thumbs-down"}) }}
<p class="mt-4 mb-3">
{{ _("Why or why not? Try to be constructive") }}

View File

@@ -54,10 +54,12 @@
{% for review in reviews %}
<tr>
<th colspan="2">
{% if review.recommends %}
{% if review.rating > 3 %}
<i class="fas fa-thumbs-up text-success mr-2"></i>
{% else %}
{% elif review.rating < 3 %}
<i class="fas fa-thumbs-down text-danger mr-2"></i>
{% else %}
<i class="fas fa-minus mr-2"></i>
{% endif %}
<a href="{{ review.thread.getViewURL() }}">
{{ review.thread.title }}
@@ -86,4 +88,4 @@
</tr>
{% endfor %}
</table>
{% endblock %}
{% endblock %}

View File

@@ -198,9 +198,11 @@
<a class="btn" href="#reviews" title="{{ _("Reviews") }}">
<i class="fas fa-star-half-alt"></i>
<span class="count">
+{{ package.reviews | selectattr("recommends") | list | length }}
+{{ package.reviews | selectattr("rating", "equalto", 5) | list | length }}
/
-{{ package.reviews | rejectattr("recommends") | list | length }}
{{ package.reviews | selectattr("rating", "equalto", 3) | list | length }}
/
-{{ package.reviews | selectattr("rating", "equalto", 1) | list | length }}
</span>
</a>
{% if package.website %}

View File

@@ -3,10 +3,12 @@
{% block title %}
{%- if thread.package -%}
{%- if thread.review -%}
{%- if thread.review.recommends -%}
{%- if thread.review.rating > 3 -%}
{%- set rating = "👍" -%}
{%- else -%}
{%- elif thread.review.rating < 3 -%}
{%- set rating = "👎" -%}
{%- else -%}
{%- set rating = "-" -%}
{%- endif -%}
{%- endif -%}
{{ rating }} {{ thread.title }} - {{ thread.package.title }}
@@ -70,10 +72,12 @@
<h1>
{% if thread.review %}
{% if thread.review.recommends %}
{% if thread.review.rating > 3 %}
<i class="fas fa-thumbs-up mr-2" style="color:#6f6;"></i>
{% else %}
{% elif thread.review.rating < 3 %}
<i class="fas fa-thumbs-down mr-2" style="color:#f66;"></i>
{% else %}
<i class="fas fa-minus mr-2" style="color:#999"></i>
{% endif %}
{% endif %}
{% if thread.private %}&#x1f512; {% endif %}{{ thread.title }}