contentdb/app/templates/macros/reviews.html

203 lines
7.0 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) %}
<form class="review-helpful-vote" 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 %}
2023-08-22 20:58:43 +02:00
<span class="badge bg-light text-dark ms-1">{{ positive }}</span>
2021-08-18 23:49:44 +02:00
{% 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 %}
2023-08-22 20:58:43 +02:00
<span class="badge bg-light text-dark ms-1">{{ negative }}</span>
2021-08-18 23:49:44 +02:00
{% 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>
<div class="col-auto p-1">
2020-07-09 05:10:09 +02:00
<a href="{{ url_for('users.profile', username=review.author.username) }}">
2023-08-25 21:49:55 +02:00
<img class="img-fluid user-photo img-thumbnail img-thumbnail-1"
src="{{ review.author.get_profile_pic_url() }}" loading="lazy">
2020-07-09 05:10:09 +02:00
</a>
</div>
<div class="col col-md-auto px-3 pt-1" 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 %}
<div class="col-md pr-0">
2020-07-09 05:10:09 +02:00
<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>
2023-08-22 20:58:43 +02:00
<a name="reply-{{ reply.id }}" class="text-muted float-end"
2020-07-09 05:10:09 +02:00
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 %}
2023-08-22 20:58:43 +02:00
<a class="btn btn-primary btn-sm ms-1 float-end"
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 %}
2024-06-09 12:50:21 +02:00
{% if review.language %}
<span class="float-end mx-2 text-muted">
{{ review.language.title }}
</span>
{% 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-08-22 20:58:43 +02:00
<a class="btn btn-primary me-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 %}
<a class="btn {% if review.thread.replies_count > 1 %} btn-primary {% else %} btn-secondary {% endif %} me-1"
href="{{ url_for('threads.view', id=review.thread.id) }}">
2023-08-22 20:58:43 +02:00
<i class="fas fa-comments me-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>
2023-08-22 20:58:43 +02:00
<div class="btn-group" role="group">
<input type="radio" class="btn-check" name="rating" id="rating-5" value="5" autocomplete="off">
<label class="btn btn-primary" for="rating-5">
<i class="fas fa-thumbs-up me-2"></i>
{{ _("Yes") }}
2023-04-15 03:37:58 +02:00
</label>
2023-08-22 20:58:43 +02:00
<input type="radio" class="btn-check" name="rating" id="rating-3" value="3" autocomplete="off">
<label class="btn btn-primary" for="rating-3">
<i class="fas fa-minus me-2"></i>
{{ _("Neutral") }}
2020-07-09 05:10:09 +02:00
</label>
2023-08-22 20:58:43 +02:00
<input type="radio" class="btn-check" name="rating" id="rating-1" value="1" autocomplete="off">
<label class="btn btn-primary" for="rating-1">
<i class="fas fa-thumbs-down me-2"></i>
{{ _("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>
2023-08-22 20:58:43 +02:00
<div class="form-group mb-3">
<label for="title" class="form-label">{{ _("Title") }}</label>
<span class="ms-1 text-danger">
<small>
<i class="fas fa-asterisk"></i>
</small>
</span>
2023-08-22 20:58:43 +02:00
<span class="ms-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">
2023-08-22 20:58:43 +02:00
<div class="btn-group me-2">
2023-08-19 01:37:50 +02:00
<button class="btn btn-primary" name="rating" value="5">
2023-08-22 20:58:43 +02:00
<i class="fas fa-thumbs-up me-1"></i>
2023-08-19 01:37:50 +02:00
{{ _("Yes") }}
</button>
<button class="btn btn-primary" name="rating" value="3">
2023-08-22 20:58:43 +02:00
<i class="fas fa-minus me-1"></i>
2023-08-19 01:37:50 +02:00
{{ _("Neutral") }}
</button>
<button class="btn btn-primary" name="rating" value="1">
2023-08-22 20:58:43 +02:00
<i class="fas fa-thumbs-down me-1"></i>
2023-08-19 01:37:50 +02:00
{{ _("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">
2023-08-22 20:58:43 +02:00
<i class="fas fa-bug me-1"></i>
{{ _("Report an issue") }}
</a>
<a class="btn btn-secondary" href="{{ url_for('threads.new', pid=package.id) }}">
<i class="fas fa-question me-1"></i>
{{ _("Ask a question") }}
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 %}