contentdb/app/templates/macros/reviews.html

190 lines
6.5 KiB
HTML
Raw Normal View History

2021-08-18 23:09:41 +02:00
{% macro render_review_vote(review, current_user, next_url) %}
{% set (positive, negative, is_positive) = review.get_totals(current_user) %}
2023-06-19 22:27:49 +02:00
<form class="-group" method="post" action="{{ review.get_vote_url(next_url) }}">
2021-08-18 23:09:41 +02:00
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
<div class="btn-group">
<button class="btn {% if is_positive == true %}btn-primary{% else %}btn-secondary{% endif %}" name="is_positive" value="yes">
{{ _("Helpful") }}
2021-08-18 23:49:44 +02:00
{% if positive > 0 %}
<span class="badge badge-light ml-1">{{ positive }}</span>
{% endif %}
2021-08-18 23:09:41 +02:00
</button>
<button class="btn {% if is_positive == false %}btn-primary{% else %}btn-secondary{% endif %}" name="is_positive" value="no">
{{ _("Unhelpful") }}
2021-08-18 23:49:44 +02:00
{% if negative > 0 %}
<span class="badge badge-light ml-1">{{ negative }}</span>
{% endif %}
2021-08-18 23:09:41 +02:00
</button>
</div>
</form>
{% endmacro %}
{% macro render_reviews(reviews, current_user, show_package_link=False) -%}
2020-07-09 05:10:09 +02:00
<ul class="comments mt-4 mb-0">
{% for review in reviews %}
2021-08-18 23:09:41 +02:00
{% set review_anchor = "review-" + (review.id | string) %}
2020-07-09 05:10:09 +02:00
<li class="row my-2 mx-0">
2021-08-18 23:09:41 +02:00
<a id="{{ review_anchor }}"></a>
2020-07-09 05:10:09 +02:00
<div class="col-md-1 p-1">
<a href="{{ url_for('users.profile', username=review.author.username) }}">
<img class="img-fluid user-photo img-thumbnail img-thumbnail-1" src="{{ review.author.get_profile_pic_url() }}">
2020-07-09 05:10:09 +02:00
</a>
</div>
<div class="col-md-auto pl-1 pr-3 pt-2 text-center" style=" font-size: 200%;">
2023-04-15 03:37:58 +02:00
{% if review.rating > 3 %}
<i class="fas fa-thumbs-up" style="color:#6f6;"></i>
2023-04-15 03:37:58 +02:00
{% elif review.rating < 3 %}
2020-07-09 05:10:09 +02:00
<i class="fas fa-thumbs-down" style="color:#f66;"></i>
2023-04-15 03:37:58 +02:00
{% else %}
<i class="fas fa-minus" style="color:#999"></i>
2020-07-09 05:10:09 +02:00
{% endif %}
</div>
{% if review.thread %}
{% set reply = review.thread.first_reply %}
2020-07-09 05:10:09 +02:00
<div class="col pr-0">
<div class="card">
<div class="card-header">
<a class="author {{ review.author.rank.name }}"
href="{{ url_for('users.profile', username=review.author.username) }}">
{{ review.author.display_name }}
2020-07-09 05:10:09 +02:00
</a>
<a name="reply-{{ reply.id }}" class="text-muted float-right"
href="{{ url_for('threads.view', id=review.thread.id) }}#reply-{{ reply.id }}">
{{ review.created_at | datetime }}
2020-07-09 05:10:09 +02:00
</a>
</div>
2021-02-23 01:01:28 +01:00
<div class="card-body markdown">
{% if current_user == review.author %}
<a class="btn btn-primary btn-sm ml-1 float-right"
2023-06-18 23:00:24 +02:00
href="{{ review.package.get_url('packages.review') }}">
2021-02-28 06:16:15 +01:00
<i class="fas fa-pen"></i>
</a>
{% endif %}
2020-07-09 05:10:09 +02:00
<p>
<strong>{{ review.thread.title }}</strong>
</p>
{{ reply.comment | markdown }}
2021-08-18 23:09:41 +02:00
<div class="btn-toolbar mt-2 mb-0">
{% if show_package_link %}
2023-06-18 23:00:24 +02:00
<a class="btn btn-primary mr-1" href="{{ review.package.get_url('packages.view') }}">
{{ _("%(title)s by %(author)s",
title="<b>" | safe + review.package.title + "</b>" | safe,
author=review.package.author.display_name) }}
</a>
{% endif %}
2021-08-18 23:09:41 +02:00
<a class="btn {% if review.thread.replies.count() > 1 %} btn-primary {% else %} btn-secondary {% endif %} mr-1"
href="{{ url_for('threads.view', id=review.thread.id) }}">
<i class="fas fa-comments mr-2"></i>
{{ _("%(num)d comments", num=review.thread.replies.count() - 1) }}
</a>
2021-08-18 23:09:41 +02:00
{{ render_review_vote(review, current_user, url_set_anchor(review_anchor)) }}
</div>
2020-07-09 05:10:09 +02:00
</div>
</div>
</div>
{% endif %}
</li>
2020-07-10 20:10:36 +02:00
{% else %}
2021-02-03 18:40:03 +01:00
<li>
2020-07-10 20:10:36 +02:00
<i>{{ _("No reviews, yet.") }}</i>
2021-02-03 18:40:03 +01:00
</li>
2020-07-09 05:10:09 +02:00
{% endfor %}
</ul>
{% endmacro %}
{% macro render_review_form(package, current_user) -%}
<div class="card mt-0 mb-4 ">
<div class="card-header">
{{ _("Review") }}
</div>
2023-06-18 23:00:24 +02:00
<form method="post" action="{{ package.get_url('packages.review') }}" class="card-body">
2020-07-09 05:10:09 +02:00
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
<p>
2022-01-14 19:25:28 +01:00
{{ _("Do you recommend this %(type)s?", type=package.type.text | lower) }}
2020-07-09 05:10:09 +02:00
</p>
<div class="btn-group btn-group-toggle" data-toggle="buttons">
<label class="btn btn-primary">
<i class="fas fa-thumbs-up mr-2"></i>
2023-04-15 03:37:58 +02:00
<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") }}
2020-07-09 05:10:09 +02:00
</label>
<label class="btn btn-primary">
<i class="fas fa-thumbs-down mr-2"></i>
2023-04-15 03:37:58 +02:00
<input type="radio" name="rating" value="1" autocomplete="off"> {{ _("No") }}
2020-07-09 05:10:09 +02:00
</label>
</div>
<p class="mt-4 mb-3">
{{ _("Why or why not? Try to be constructive") }}
</p>
<div class="form-group">
<label for="title">{{ _("Title") }}</label>
<span class="ml-1 text-danger">
<small>
<i class="fas fa-asterisk"></i>
</small>
</span>
<span class="ml-3 text-muted">
{{ _("Required") }}
</span>
2020-07-09 05:10:09 +02:00
<input class="form-control" id="title" name="title" required="" type="text">
</div>
2020-07-29 18:33:12 +02:00
<textarea class="form-control markdown" required maxlength=2000 name="comment"></textarea><br />
2020-07-09 05:10:09 +02:00
<input class="btn btn-primary" type="submit" value="{{ _('Post Review') }}" />
</form>
</div>
{% endmacro %}
{% macro render_review_preview(package, current_user) -%}
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
<div class="card mt-0 mb-4 ">
<div class="card-header">
{{ _("Review") }}
</div>
2023-06-18 23:00:24 +02:00
<form method="post" action="{{ package.get_url('packages.review') }}" class="card-body">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
2020-07-09 05:10:09 +02:00
<p>
2022-01-14 19:25:28 +01:00
{{ _("Do you recommend this %(type)s?", type=package.type.text | lower) }}
2020-07-09 05:10:09 +02:00
</p>
2023-08-19 01:37:50 +02:00
<div class="btn-toolbar" role="toolbar">
<div class="btn-group mr-2">
<button class="btn btn-primary" name="rating" value="5">
<i class="fas fa-thumbs-up mr-1"></i>
{{ _("Yes") }}
</button>
<button class="btn btn-primary" name="rating" value="3">
<i class="fas fa-minus mr-1"></i>
{{ _("Neutral") }}
</button>
<button class="btn btn-primary" name="rating" value="1">
<i class="fas fa-thumbs-down mr-1"></i>
{{ _("No") }}
</button>
</div>
<div class="btn-group">
<a class="btn btn-secondary" href="{{ package.issueTracker or url_for('threads.new', pid=package.id) }}" rel="ugc">
<i class="fas fa-bug mr-1"></i>
2023-08-19 01:43:42 +02:00
{{ _("Report an Issue") }}
2023-08-19 01:37:50 +02:00
</a>
</div>
2020-07-09 05:10:09 +02:00
</div>
</form>
2020-07-09 05:10:09 +02:00
</div>
{% endmacro %}