- Added CompanyRecommendation system - Made company pages public (removed @login_required) - CSS refactor: inline styles instead of external fluent CSS - Added release notes page - Added admin recommendations panel - Company logos (webp format) - Docker compose configuration Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
617 lines
18 KiB
HTML
Executable File
617 lines
18 KiB
HTML
Executable File
{% extends "base.html" %}
|
|
|
|
{% block title %}Moderacja Rekomendacji - Norda Biznes Hub{% endblock %}
|
|
|
|
{% block extra_css %}
|
|
<style>
|
|
.admin-header {
|
|
margin-bottom: var(--spacing-xl);
|
|
}
|
|
|
|
.admin-header h1 {
|
|
font-size: var(--font-size-3xl);
|
|
color: var(--text-primary);
|
|
}
|
|
|
|
.stats-grid {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
|
|
gap: var(--spacing-lg);
|
|
margin-bottom: var(--spacing-2xl);
|
|
}
|
|
|
|
.stat-card {
|
|
background: var(--surface);
|
|
padding: var(--spacing-lg);
|
|
border-radius: var(--radius-lg);
|
|
box-shadow: var(--shadow);
|
|
text-align: center;
|
|
}
|
|
|
|
.stat-value {
|
|
font-size: var(--font-size-3xl);
|
|
font-weight: 700;
|
|
color: var(--primary);
|
|
}
|
|
|
|
.stat-label {
|
|
color: var(--text-secondary);
|
|
font-size: var(--font-size-sm);
|
|
margin-top: var(--spacing-xs);
|
|
}
|
|
|
|
.filter-tabs {
|
|
display: flex;
|
|
gap: var(--spacing-sm);
|
|
margin-bottom: var(--spacing-lg);
|
|
border-bottom: 2px solid var(--border);
|
|
padding-bottom: var(--spacing-sm);
|
|
}
|
|
|
|
.filter-tab {
|
|
padding: var(--spacing-sm) var(--spacing-md);
|
|
background: transparent;
|
|
border: none;
|
|
color: var(--text-secondary);
|
|
cursor: pointer;
|
|
font-size: var(--font-size-base);
|
|
font-weight: 500;
|
|
transition: var(--transition);
|
|
border-bottom: 2px solid transparent;
|
|
margin-bottom: -2px;
|
|
}
|
|
|
|
.filter-tab:hover {
|
|
color: var(--text-primary);
|
|
}
|
|
|
|
.filter-tab.active {
|
|
color: var(--primary);
|
|
border-bottom-color: var(--primary);
|
|
}
|
|
|
|
.section {
|
|
background: var(--surface);
|
|
padding: var(--spacing-xl);
|
|
border-radius: var(--radius-lg);
|
|
box-shadow: var(--shadow);
|
|
margin-bottom: var(--spacing-xl);
|
|
}
|
|
|
|
.section h2 {
|
|
font-size: var(--font-size-xl);
|
|
margin-bottom: var(--spacing-lg);
|
|
color: var(--text-primary);
|
|
border-bottom: 2px solid var(--border);
|
|
padding-bottom: var(--spacing-sm);
|
|
}
|
|
|
|
.recommendations-table {
|
|
width: 100%;
|
|
border-collapse: collapse;
|
|
}
|
|
|
|
.recommendations-table th,
|
|
.recommendations-table td {
|
|
padding: var(--spacing-md);
|
|
text-align: left;
|
|
border-bottom: 1px solid var(--border);
|
|
}
|
|
|
|
.recommendations-table th {
|
|
font-weight: 600;
|
|
color: var(--text-secondary);
|
|
font-size: var(--font-size-sm);
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.5px;
|
|
}
|
|
|
|
.recommendations-table tr:hover {
|
|
background: var(--background);
|
|
}
|
|
|
|
.recommendation-text {
|
|
max-width: 300px;
|
|
max-height: 60px;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
display: -webkit-box;
|
|
-webkit-line-clamp: 3;
|
|
-webkit-box-orient: vertical;
|
|
font-size: var(--font-size-sm);
|
|
color: var(--text-primary);
|
|
line-height: 1.4;
|
|
}
|
|
|
|
.recommendation-meta {
|
|
font-size: var(--font-size-sm);
|
|
color: var(--text-secondary);
|
|
}
|
|
|
|
.recommendation-company {
|
|
font-weight: 500;
|
|
color: var(--text-primary);
|
|
text-decoration: none;
|
|
}
|
|
|
|
.recommendation-company:hover {
|
|
color: var(--primary);
|
|
}
|
|
|
|
.badge {
|
|
display: inline-block;
|
|
padding: 2px 8px;
|
|
border-radius: var(--radius-sm);
|
|
font-size: var(--font-size-xs);
|
|
font-weight: 500;
|
|
text-transform: uppercase;
|
|
}
|
|
|
|
.badge-pending {
|
|
background: #FEF3C7;
|
|
color: #92400E;
|
|
}
|
|
|
|
.badge-approved {
|
|
background: #D1FAE5;
|
|
color: #065F46;
|
|
}
|
|
|
|
.badge-rejected {
|
|
background: #FEE2E2;
|
|
color: #991B1B;
|
|
}
|
|
|
|
.action-buttons {
|
|
display: flex;
|
|
gap: var(--spacing-xs);
|
|
}
|
|
|
|
.btn-icon {
|
|
width: 32px;
|
|
height: 32px;
|
|
padding: 0;
|
|
display: inline-flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
border-radius: var(--radius);
|
|
border: 1px solid var(--border);
|
|
background: var(--surface);
|
|
cursor: pointer;
|
|
transition: var(--transition);
|
|
}
|
|
|
|
.btn-icon:hover {
|
|
background: var(--background);
|
|
}
|
|
|
|
.btn-icon.approve {
|
|
background: #D1FAE5;
|
|
border-color: #10B981;
|
|
color: #065F46;
|
|
}
|
|
|
|
.btn-icon.approve:hover {
|
|
background: #10B981;
|
|
color: white;
|
|
}
|
|
|
|
.btn-icon.reject {
|
|
background: #FEE2E2;
|
|
border-color: #EF4444;
|
|
color: #991B1B;
|
|
}
|
|
|
|
.btn-icon.reject:hover {
|
|
background: #EF4444;
|
|
color: white;
|
|
}
|
|
|
|
.btn-icon.danger:hover {
|
|
background: var(--error);
|
|
border-color: var(--error);
|
|
color: white;
|
|
}
|
|
|
|
.btn-icon svg {
|
|
width: 16px;
|
|
height: 16px;
|
|
}
|
|
|
|
.empty-state {
|
|
text-align: center;
|
|
padding: var(--spacing-2xl);
|
|
color: var(--text-secondary);
|
|
}
|
|
|
|
/* Modal for rejection reason */
|
|
.modal {
|
|
display: none;
|
|
position: fixed;
|
|
z-index: 1000;
|
|
left: 0;
|
|
top: 0;
|
|
width: 100%;
|
|
height: 100%;
|
|
background-color: rgba(0, 0, 0, 0.5);
|
|
align-items: center;
|
|
justify-content: center;
|
|
}
|
|
|
|
.modal.active {
|
|
display: flex;
|
|
}
|
|
|
|
.modal-content {
|
|
background: var(--surface);
|
|
padding: var(--spacing-xl);
|
|
border-radius: var(--radius-lg);
|
|
max-width: 500px;
|
|
width: 90%;
|
|
box-shadow: var(--shadow-lg);
|
|
}
|
|
|
|
.modal-header {
|
|
font-size: var(--font-size-xl);
|
|
margin-bottom: var(--spacing-md);
|
|
color: var(--text-primary);
|
|
}
|
|
|
|
.modal-body {
|
|
margin-bottom: var(--spacing-lg);
|
|
}
|
|
|
|
.modal-footer {
|
|
display: flex;
|
|
justify-content: flex-end;
|
|
gap: var(--spacing-sm);
|
|
}
|
|
|
|
.form-group {
|
|
margin-bottom: var(--spacing-md);
|
|
}
|
|
|
|
.form-label {
|
|
display: block;
|
|
margin-bottom: var(--spacing-xs);
|
|
color: var(--text-secondary);
|
|
font-size: var(--font-size-sm);
|
|
font-weight: 500;
|
|
}
|
|
|
|
.form-control {
|
|
width: 100%;
|
|
padding: var(--spacing-sm);
|
|
border: 1px solid var(--border);
|
|
border-radius: var(--radius);
|
|
font-size: var(--font-size-base);
|
|
font-family: inherit;
|
|
resize: vertical;
|
|
}
|
|
|
|
.form-control:focus {
|
|
outline: none;
|
|
border-color: var(--primary);
|
|
}
|
|
|
|
.btn {
|
|
padding: var(--spacing-sm) var(--spacing-md);
|
|
border: none;
|
|
border-radius: var(--radius);
|
|
font-size: var(--font-size-base);
|
|
font-weight: 500;
|
|
cursor: pointer;
|
|
transition: var(--transition);
|
|
}
|
|
|
|
.btn-primary {
|
|
background: var(--primary);
|
|
color: white;
|
|
}
|
|
|
|
.btn-primary:hover {
|
|
opacity: 0.9;
|
|
}
|
|
|
|
.btn-secondary {
|
|
background: var(--background);
|
|
color: var(--text-secondary);
|
|
}
|
|
|
|
.btn-secondary:hover {
|
|
background: var(--border);
|
|
}
|
|
|
|
@media (max-width: 768px) {
|
|
.recommendations-table {
|
|
font-size: var(--font-size-sm);
|
|
}
|
|
|
|
.recommendations-table th:nth-child(3),
|
|
.recommendations-table td:nth-child(3) {
|
|
display: none;
|
|
}
|
|
|
|
.recommendation-text {
|
|
max-width: 200px;
|
|
}
|
|
}
|
|
</style>
|
|
{% endblock %}
|
|
|
|
{% block content %}
|
|
<div class="admin-header">
|
|
<h1>⭐ Moderacja Rekomendacji</h1>
|
|
<p class="text-muted">Zarządzaj rekomendacjami firm członkowskich</p>
|
|
</div>
|
|
|
|
<!-- Stats Grid -->
|
|
<div class="stats-grid">
|
|
<div class="stat-card">
|
|
<div class="stat-value">{{ total_recommendations }}</div>
|
|
<div class="stat-label">Wszystkich</div>
|
|
</div>
|
|
<div class="stat-card">
|
|
<div class="stat-value" style="color: #F59E0B;">{{ pending_count }}</div>
|
|
<div class="stat-label">Oczekujących</div>
|
|
</div>
|
|
<div class="stat-card">
|
|
<div class="stat-value" style="color: #10B981;">{{ approved_count }}</div>
|
|
<div class="stat-label">Zatwierdzonych</div>
|
|
</div>
|
|
<div class="stat-card">
|
|
<div class="stat-value" style="color: #EF4444;">{{ rejected_count }}</div>
|
|
<div class="stat-label">Odrzuconych</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Recommendations Section -->
|
|
<div class="section">
|
|
<h2>Rekomendacje</h2>
|
|
|
|
<!-- Filter Tabs -->
|
|
<div class="filter-tabs">
|
|
<button class="filter-tab active" data-filter="all">Wszystkie</button>
|
|
<button class="filter-tab" data-filter="pending">Oczekujące ({{ pending_count }})</button>
|
|
<button class="filter-tab" data-filter="approved">Zatwierdzone ({{ approved_count }})</button>
|
|
<button class="filter-tab" data-filter="rejected">Odrzucone ({{ rejected_count }})</button>
|
|
</div>
|
|
|
|
{% if recommendations %}
|
|
<table class="recommendations-table">
|
|
<thead>
|
|
<tr>
|
|
<th>Firma</th>
|
|
<th>Rekomendujący</th>
|
|
<th>Treść</th>
|
|
<th>Data</th>
|
|
<th>Status</th>
|
|
<th>Akcje</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{% for rec in recommendations %}
|
|
<tr data-recommendation-id="{{ rec.id }}" data-status="{{ rec.status }}">
|
|
<td>
|
|
<a href="{{ url_for('company_detail_by_slug', slug=rec.company.slug) }}"
|
|
class="recommendation-company"
|
|
target="_blank">
|
|
{{ rec.company.name }}
|
|
</a>
|
|
{% if rec.service_category %}
|
|
<div class="recommendation-meta">{{ rec.service_category }}</div>
|
|
{% endif %}
|
|
</td>
|
|
<td>
|
|
<div class="recommendation-meta">
|
|
{{ rec.user.name or rec.user.email.split('@')[0] }}
|
|
{% if rec.user.company %}
|
|
<br>{{ rec.user.company.name }}
|
|
{% endif %}
|
|
</div>
|
|
</td>
|
|
<td>
|
|
<div class="recommendation-text" title="{{ rec.recommendation_text }}">
|
|
{{ rec.recommendation_text }}
|
|
</div>
|
|
</td>
|
|
<td class="recommendation-meta">{{ rec.created_at.strftime('%d.%m.%Y') }}</td>
|
|
<td>
|
|
{% if rec.status == 'pending' %}
|
|
<span class="badge badge-pending">Oczekuje</span>
|
|
{% elif rec.status == 'approved' %}
|
|
<span class="badge badge-approved">Zatwierdzona</span>
|
|
{% elif rec.status == 'rejected' %}
|
|
<span class="badge badge-rejected">Odrzucona</span>
|
|
{% endif %}
|
|
</td>
|
|
<td>
|
|
<div class="action-buttons">
|
|
{% if rec.status == 'pending' %}
|
|
<button class="btn-icon approve"
|
|
onclick="approveRecommendation({{ rec.id }})"
|
|
title="Zatwierdź">
|
|
<svg fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
|
|
<polyline points="20 6 9 17 4 12"></polyline>
|
|
</svg>
|
|
</button>
|
|
<button class="btn-icon reject"
|
|
onclick="openRejectModal({{ rec.id }}, '{{ rec.company.name|e }}')"
|
|
title="Odrzuć">
|
|
<svg fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
|
|
<line x1="18" y1="6" x2="6" y2="18"></line>
|
|
<line x1="6" y1="6" x2="18" y2="18"></line>
|
|
</svg>
|
|
</button>
|
|
{% elif rec.status == 'rejected' %}
|
|
<button class="btn-icon approve"
|
|
onclick="approveRecommendation({{ rec.id }})"
|
|
title="Zatwierdź">
|
|
<svg fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
|
|
<polyline points="20 6 9 17 4 12"></polyline>
|
|
</svg>
|
|
</button>
|
|
{% endif %}
|
|
<button class="btn-icon danger"
|
|
onclick="deleteRecommendation({{ rec.id }}, '{{ rec.company.name|e }}')"
|
|
title="Usuń">
|
|
<svg fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
|
|
<polyline points="3 6 5 6 21 6"></polyline>
|
|
<path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"></path>
|
|
</svg>
|
|
</button>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
{% else %}
|
|
<div class="empty-state">
|
|
<p>Brak rekomendacji</p>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
|
|
<!-- Rejection Modal -->
|
|
<div id="rejectModal" class="modal">
|
|
<div class="modal-content">
|
|
<div class="modal-header">Odrzuć rekomendację</div>
|
|
<div class="modal-body">
|
|
<div class="form-group">
|
|
<label class="form-label">Powód odrzucenia (opcjonalnie)</label>
|
|
<textarea id="rejectionReason"
|
|
class="form-control"
|
|
rows="4"
|
|
placeholder="Wprowadź powód odrzucenia..."></textarea>
|
|
</div>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button class="btn btn-secondary" onclick="closeRejectModal()">Anuluj</button>
|
|
<button class="btn btn-primary" onclick="confirmReject()">Odrzuć</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endblock %}
|
|
|
|
{% block extra_js %}
|
|
const csrfToken = '{{ csrf_token() }}';
|
|
let currentRecommendationId = null;
|
|
|
|
function showMessage(message, type) {
|
|
// Simple alert for now - could be improved with toast notifications
|
|
alert(message);
|
|
}
|
|
|
|
// Filter tabs functionality
|
|
document.querySelectorAll('.filter-tab').forEach(tab => {
|
|
tab.addEventListener('click', function() {
|
|
// Update active tab
|
|
document.querySelectorAll('.filter-tab').forEach(t => t.classList.remove('active'));
|
|
this.classList.add('active');
|
|
|
|
// Filter rows
|
|
const filter = this.dataset.filter;
|
|
document.querySelectorAll('[data-recommendation-id]').forEach(row => {
|
|
if (filter === 'all' || row.dataset.status === filter) {
|
|
row.style.display = '';
|
|
} else {
|
|
row.style.display = 'none';
|
|
}
|
|
});
|
|
});
|
|
});
|
|
|
|
async function approveRecommendation(recommendationId) {
|
|
try {
|
|
const response = await fetch(`/admin/recommendations/${recommendationId}/approve`, {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
'X-CSRFToken': csrfToken
|
|
}
|
|
});
|
|
|
|
const data = await response.json();
|
|
if (data.success) {
|
|
location.reload();
|
|
} else {
|
|
showMessage(data.error || 'Wystąpił błąd', 'error');
|
|
}
|
|
} catch (error) {
|
|
showMessage('Błąd połączenia', 'error');
|
|
}
|
|
}
|
|
|
|
function openRejectModal(recommendationId, companyName) {
|
|
currentRecommendationId = recommendationId;
|
|
document.getElementById('rejectionReason').value = '';
|
|
document.getElementById('rejectModal').classList.add('active');
|
|
}
|
|
|
|
function closeRejectModal() {
|
|
currentRecommendationId = null;
|
|
document.getElementById('rejectModal').classList.remove('active');
|
|
}
|
|
|
|
async function confirmReject() {
|
|
if (!currentRecommendationId) return;
|
|
|
|
const reason = document.getElementById('rejectionReason').value.trim();
|
|
|
|
try {
|
|
const response = await fetch(`/admin/recommendations/${currentRecommendationId}/reject`, {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
'X-CSRFToken': csrfToken
|
|
},
|
|
body: JSON.stringify({ reason: reason })
|
|
});
|
|
|
|
const data = await response.json();
|
|
if (data.success) {
|
|
closeRejectModal();
|
|
location.reload();
|
|
} else {
|
|
showMessage(data.error || 'Wystąpił błąd', 'error');
|
|
}
|
|
} catch (error) {
|
|
showMessage('Błąd połączenia', 'error');
|
|
}
|
|
}
|
|
|
|
async function deleteRecommendation(recommendationId, companyName) {
|
|
if (!confirm(`Czy na pewno chcesz usunąć rekomendację dla firmy "${companyName}"?\n\nTa operacja jest nieodwracalna.`)) {
|
|
return;
|
|
}
|
|
|
|
try {
|
|
const response = await fetch(`/api/recommendations/${recommendationId}/delete`, {
|
|
method: 'DELETE',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
'X-CSRFToken': csrfToken
|
|
}
|
|
});
|
|
|
|
const data = await response.json();
|
|
if (data.success) {
|
|
document.querySelector(`tr[data-recommendation-id="${recommendationId}"]`).remove();
|
|
showMessage('Rekomendacja została usunięta', 'success');
|
|
} else {
|
|
showMessage(data.error || 'Wystąpił błąd', 'error');
|
|
}
|
|
} catch (error) {
|
|
showMessage('Błąd połączenia', 'error');
|
|
}
|
|
}
|
|
|
|
// Close modal on background click
|
|
document.getElementById('rejectModal').addEventListener('click', function(e) {
|
|
if (e.target === this) {
|
|
closeRejectModal();
|
|
}
|
|
});
|
|
{% endblock %}
|