pewpewpew/templates/admin/reviews.html

315 lines
9.4 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{% extends "base.html" %}
{% block content %}
<h2>Модерация отзывов</h2>
{% with messages = get_flashed_messages(with_categories=true) %}
{% if messages %}
{% for category, message in messages %}
<div class="alert alert-{{ category }}">{{ message }}</div>
{% endfor %}
{% endif %}
{% endwith %}
<div class="filters">
<h3>Фильтры и сортировка</h3>
<div class="filter-bar">
<label>Сортировка:</label>
<select onchange="window.location.href='?sort='+this.value+'&status={{ status }}&rating={{ rating }}'">
<option value="newest" {% if sort == 'newest' %}selected{% endif %}>Новые сначала</option>
<option value="oldest" {% if sort == 'oldest' %}selected{% endif %}>Старые сначала</option>
<option value="rating_high" {% if sort == 'rating_high' %}selected{% endif %}>Высокий рейтинг</option>
<option value="rating_low" {% if sort == 'rating_low' %}selected{% endif %}>Низкий рейтинг</option>
</select>
<label>Статус:</label>
<select onchange="window.location.href='?sort={{ sort }}&status='+this.value+'&rating={{ rating }}'">
<option value="all" {% if status == 'all' %}selected{% endif %}>Все</option>
<option value="pending" {% if status == 'pending' %}selected{% endif %}>На модерации</option>
<option value="approved" {% if status == 'approved' %}selected{% endif %}>Одобрены</option>
<option value="rejected" {% if status == 'rejected' %}selected{% endif %}>Отклонены</option>
</select>
<label>Оценка:</label>
<select onchange="window.location.href='?sort={{ sort }}&status={{ status }}&rating='+this.value">
<option value="all" {% if rating == 'all' %}selected{% endif %}>Все оценки</option>
<option value="5" {% if rating == '5' %}selected{% endif %}>⭐⭐⭐⭐⭐</option>
<option value="4" {% if rating == '4' %}selected{% endif %}>⭐⭐⭐⭐</option>
<option value="3" {% if rating == '3' %}selected{% endif %}>⭐⭐⭐</option>
<option value="2" {% if rating == '2' %}selected{% endif %}>⭐⭐</option>
<option value="1" {% if rating == '1' %}selected{% endif %}>⭐</option>
</select>
</div>
</div>
<div class="admin-table">
<table>
<thead>
<tr>
<th>ID</th>
<th>Пользователь</th>
<th>Заказ</th>
<th>Оценка</th>
<th>Отзыв</th>
<th>Статус</th>
<th>Дата</th>
<th>Действия</th>
</tr>
</thead>
<tbody>
{% for review in reviews %}
<tr class="review-row {% if review.status == 'pending' %}row-pending{% endif %}">
<td>{{ review.id }}</td>
<td><strong>{{ review.username }}</strong></td>
<td>Заказ #{{ review.order_id }}</td>
<td>
<div class="rating">
{% for i in range(5) %}
{% if i < review.rating %}
★
{% else %}
☆
{% endif %}
{% endfor %}
</div>
</td>
<td class="review-comment">
<div class="comment-text">{{ review.comment }}</div>
</td>
<td>
<span class="status-badge status-{{ review.status }}">
{% if review.status == 'pending' %}На модерации
{% elif review.status == 'approved' %}Одобрен
{% elif review.status == 'rejected' %}Отклонен
{% endif %}
</span>
</td>
<td>{{ review.created_at[:16] }}</td>
<td>
<form method="POST" action="{{ url_for('moderate_review', review_id=review.id) }}?sort={{ sort }}&status={{ status }}&rating={{ rating }}" style="display: inline;">
<select name="status" onchange="this.form.submit()" class="status-select">
<option value="pending" {% if review.status == 'pending' %}selected{% endif %}>На модерации</option>
<option value="approved" {% if review.status == 'approved' %}selected{% endif %}>Одобрить</option>
<option value="rejected" {% if review.status == 'rejected' %}selected{% endif %}>Отклонить</option>
</select>
</form>
<form method="POST" action="{{ url_for('delete_review', review_id=review.id) }}?sort={{ sort }}&status={{ status }}&rating={{ rating }}" style="display: inline;" onsubmit="return confirm('Удалить отзыв?')">
<button type="submit" class="btn btn-danger btn-sm">Удалить</button>
</form>
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% if not reviews %}
<div class="empty-state">
<p>Нет отзывов для отображения</p>
</div>
{% endif %}
</div>
<style>
.filters {
background: white;
padding: 1rem;
margin-bottom: 1rem;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.filters h3 {
margin-top: 0;
margin-bottom: 1rem;
color: #4a2c2c;
font-size: 1.2rem;
}
.filter-bar {
display: flex;
gap: 1.5rem;
flex-wrap: wrap;
align-items: center;
}
.filter-bar label {
font-weight: bold;
color: #4a2c2c;
}
.filter-bar select {
padding: 0.5rem;
border: 1px solid #ddd;
border-radius: 4px;
font-size: 0.9rem;
cursor: pointer;
}
.admin-table {
overflow-x: auto;
background: white;
border-radius: 8px;
padding: 1rem;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.admin-table table {
width: 100%;
border-collapse: collapse;
}
.admin-table th,
.admin-table td {
padding: 0.75rem;
text-align: left;
border-bottom: 1px solid #ddd;
vertical-align: top;
}
.admin-table th {
background-color: #4a2c2c;
color: white;
font-weight: bold;
}
.admin-table tr:hover {
background-color: #f5f5f5;
}
.row-pending {
background-color: #fff3e0;
}
.rating {
color: #ffc107;
font-size: 1.1rem;
letter-spacing: 2px;
}
.review-comment {
max-width: 300px;
}
.comment-text {
word-wrap: break-word;
line-height: 1.4;
margin-bottom: 0.25rem;
}
.status-badge {
display: inline-block;
padding: 0.25rem 0.5rem;
border-radius: 4px;
font-size: 0.8rem;
font-weight: bold;
text-align: center;
}
.status-pending {
background-color: #ffc107;
color: #856404;
}
.status-approved {
background-color: #28a745;
color: white;
}
.status-rejected {
background-color: #dc3545;
color: white;
}
.status-select {
padding: 0.3rem;
border: 1px solid #ddd;
border-radius: 4px;
font-size: 0.85rem;
margin-bottom: 0.25rem;
cursor: pointer;
}
.btn-sm {
padding: 0.25rem 0.5rem;
font-size: 0.85rem;
display: inline-block;
margin: 0.25rem 0;
text-decoration: none;
border: none;
border-radius: 4px;
cursor: pointer;
}
.btn-danger {
background-color: #dc3545;
color: white;
}
.btn-danger:hover {
background-color: #c82333;
}
.empty-state {
text-align: center;
padding: 3rem;
color: #666;
}
.alert {
padding: 0.75rem;
margin-bottom: 1rem;
border-radius: 4px;
}
.alert-success {
background-color: #d4edda;
color: #155724;
border: 1px solid #c3e6cb;
}
.alert-danger {
background-color: #f8d7da;
color: #721c24;
border: 1px solid #f5c6cb;
}
.alert-warning {
background-color: #fff3cd;
color: #856404;
border: 1px solid #ffeeba;
}
@media (max-width: 768px) {
.filter-bar {
flex-direction: column;
align-items: flex-start;
gap: 0.5rem;
}
.filter-bar select {
width: 100%;
}
.admin-table th,
.admin-table td {
padding: 0.5rem;
font-size: 0.85rem;
}
.review-comment {
max-width: 200px;
}
.status-select {
width: 100%;
margin-bottom: 0.5rem;
}
.btn-sm {
width: 100%;
text-align: center;
}
}
</style>
{% endblock %}