180 lines
8.0 KiB
HTML
180 lines
8.0 KiB
HTML
{% extends "admin/base.html" %}
|
|
|
|
{% block title %}Post Management - Admin{% endblock %}
|
|
|
|
{% block admin_content %}
|
|
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pb-2 mb-3 border-bottom">
|
|
<h1 class="h2">Posts</h1>
|
|
<div class="btn-toolbar mb-2 mb-md-0">
|
|
<div class="btn-group me-2">
|
|
<a href="{{ url_for('admin.posts', status='all') }}"
|
|
class="btn btn-sm {{ 'btn-primary' if status == 'all' else 'btn-outline-secondary' }}">
|
|
All Posts
|
|
</a>
|
|
<a href="{{ url_for('admin.posts', status='published') }}"
|
|
class="btn btn-sm {{ 'btn-primary' if status == 'published' else 'btn-outline-secondary' }}">
|
|
Published
|
|
</a>
|
|
<a href="{{ url_for('admin.posts', status='pending') }}"
|
|
class="btn btn-sm {{ 'btn-primary' if status == 'pending' else 'btn-outline-secondary' }}">
|
|
Pending Review
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
{% if posts.items %}
|
|
<div class="card">
|
|
<div class="card-header py-3">
|
|
<h6 class="m-0 fw-bold text-primary">
|
|
{% if status == 'pending' %}
|
|
Posts Pending Review ({{ posts.total }})
|
|
{% elif status == 'published' %}
|
|
Published Posts ({{ posts.total }})
|
|
{% else %}
|
|
All Posts ({{ posts.total }})
|
|
{% endif %}
|
|
</h6>
|
|
</div>
|
|
<div class="card-body p-0">
|
|
<div class="table-responsive">
|
|
<table class="table table-hover mb-0">
|
|
<thead>
|
|
<tr>
|
|
<th style="width: 40%;">Title</th>
|
|
<th style="width: 15%;">Author</th>
|
|
<th style="width: 10%;">Status</th>
|
|
<th style="width: 10%;">Difficulty</th>
|
|
<th style="width: 15%;">Created</th>
|
|
<th style="width: 10%;">Actions</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{% for post in posts.items %}
|
|
<tr>
|
|
<td>
|
|
<div>
|
|
<a href="{{ url_for('admin.post_detail', post_id=post.id) }}" class="text-decoration-none fw-bold">
|
|
{{ post.title }}
|
|
</a>
|
|
{% if post.subtitle %}
|
|
<br><small class="text-muted">{{ post.subtitle[:80] }}{% if post.subtitle|length > 80 %}...{% endif %}</small>
|
|
{% endif %}
|
|
{% if post.gpx_files.count() > 0 %}
|
|
<!-- Map iframe removed as requested -->
|
|
{% endif %}
|
|
</div>
|
|
</td>
|
|
<td>
|
|
<a href="{{ url_for('admin.user_detail', user_id=post.author.id) }}" class="text-decoration-none">
|
|
{{ post.author.nickname }}
|
|
</a>
|
|
</td>
|
|
<td>
|
|
{% if post.published %}
|
|
<span class="badge bg-success">Published</span>
|
|
{% else %}
|
|
<span class="badge bg-warning text-dark">Pending</span>
|
|
{% endif %}
|
|
</td>
|
|
<td>
|
|
<span class="badge bg-info">{{ post.get_difficulty_label() }}</span>
|
|
</td>
|
|
<td>
|
|
<small>{{ post.created_at.strftime('%Y-%m-%d<br>%H:%M')|safe }}</small>
|
|
</td>
|
|
<td>
|
|
<div class="btn-group" role="group">
|
|
<a href="{{ url_for('admin.post_detail', post_id=post.id) }}"
|
|
class="btn btn-sm btn-outline-info" title="View Details">
|
|
<i class="fas fa-eye"></i>
|
|
</a>
|
|
|
|
{% if not post.published %}
|
|
<form method="POST" action="{{ url_for('admin.publish_post', post_id=post.id) }}" class="d-inline">
|
|
<button type="submit" class="btn btn-sm btn-success" title="Publish"
|
|
onclick="return confirm('Publish this post?')">
|
|
<i class="fas fa-check"></i>
|
|
</button>
|
|
</form>
|
|
{% else %}
|
|
<form method="POST" action="{{ url_for('admin.unpublish_post', post_id=post.id) }}" class="d-inline">
|
|
<button type="submit" class="btn btn-sm btn-warning" title="Unpublish"
|
|
onclick="return confirm('Unpublish this post?')">
|
|
<i class="fas fa-times"></i>
|
|
</button>
|
|
</form>
|
|
{% endif %}
|
|
|
|
<form method="POST" action="{{ url_for('admin.delete_post', post_id=post.id) }}" class="d-inline">
|
|
<button type="submit" class="btn btn-sm btn-danger" title="Delete"
|
|
onclick="return confirm('Are you sure you want to delete this post? This action cannot be undone.')">
|
|
<i class="fas fa-trash"></i>
|
|
</button>
|
|
</form>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Pagination -->
|
|
{% if posts.pages > 1 %}
|
|
<nav aria-label="Posts pagination" class="mt-4">
|
|
<ul class="pagination justify-content-center">
|
|
{% if posts.has_prev %}
|
|
<li class="page-item">
|
|
<a class="page-link" href="{{ url_for('admin.posts', page=posts.prev_num, status=status) }}">Previous</a>
|
|
</li>
|
|
{% endif %}
|
|
|
|
{% for page_num in posts.iter_pages() %}
|
|
{% if page_num %}
|
|
{% if page_num != posts.page %}
|
|
<li class="page-item">
|
|
<a class="page-link" href="{{ url_for('admin.posts', page=page_num, status=status) }}">{{ page_num }}</a>
|
|
</li>
|
|
{% else %}
|
|
<li class="page-item active">
|
|
<span class="page-link">{{ page_num }}</span>
|
|
</li>
|
|
{% endif %}
|
|
{% else %}
|
|
<li class="page-item disabled">
|
|
<span class="page-link">…</span>
|
|
</li>
|
|
{% endif %}
|
|
{% endfor %}
|
|
|
|
{% if posts.has_next %}
|
|
<li class="page-item">
|
|
<a class="page-link" href="{{ url_for('admin.posts', page=posts.next_num, status=status) }}">Next</a>
|
|
</li>
|
|
{% endif %}
|
|
</ul>
|
|
</nav>
|
|
{% endif %}
|
|
|
|
{% else %}
|
|
<div class="card">
|
|
<div class="card-body text-center py-5">
|
|
<i class="fas fa-file-alt fa-3x text-muted mb-3"></i>
|
|
<h5 class="text-muted">No posts found</h5>
|
|
<p class="text-muted">
|
|
{% if status == 'pending' %}
|
|
There are no posts waiting for review.
|
|
{% elif status == 'published' %}
|
|
No posts have been published yet.
|
|
{% else %}
|
|
No posts have been created yet.
|
|
{% endif %}
|
|
</p>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
{% endblock %}
|