Add missing model files: post.py and category.py

This commit is contained in:
2025-09-21 21:18:54 +02:00
parent 8b7ab9d66e
commit 7ec30b8d5e
5 changed files with 606 additions and 0 deletions

View File

@@ -0,0 +1,117 @@
{% extends "dashboard/base.html" %}
{% block page_title %}Gestione Progetti{% endblock %}
{% block page_actions %}
<a href="{{ url_for('dashboard.new_project') }}" class="btn btn-primary">
<i class="bi bi-plus"></i> Nuovo Progetto
</a>
{% endblock %}
{% block content %}
<div class="card">
<div class="card-body">
{% if projects %}
<div class="table-responsive">
<table class="table table-hover">
<thead>
<tr>
<th>Titolo</th>
<th>Stato</th>
<th>Featured</th>
<th>Creato</th>
<th>Azioni</th>
</tr>
</thead>
<tbody>
{% for project in projects %}
<tr>
<td>
<strong>{{ project.title }}</strong>
{% if project.description %}
<br><small class="text-muted">{{ project.description[:100] }}...</small>
{% endif %}
</td>
<td>
{% if project.is_published %}
<span class="badge bg-success">Pubblicato</span>
{% else %}
<span class="badge bg-secondary">Bozza</span>
{% endif %}
</td>
<td>
{% if project.is_featured %}
<span class="badge bg-warning">Featured</span>
{% else %}
<span class="text-muted">-</span>
{% endif %}
</td>
<td>{{ project.created_at.strftime('%d/%m/%Y') if project.created_at else 'N/D' }}</td>
<td>
<div class="btn-group" role="group">
<a href="{{ url_for('dashboard.edit_project', project_id=project.id) }}"
class="btn btn-sm btn-outline-primary" title="Modifica">
<i class="bi bi-pencil"></i>
</a>
<form method="POST" action="{{ url_for('dashboard.delete_project', project_id=project.id) }}"
style="display: inline;"
onsubmit="return confirm('Sei sicuro di voler eliminare questo progetto?')">
<button type="submit" class="btn btn-sm btn-outline-danger" title="Elimina">
<i class="bi bi-trash"></i>
</button>
</form>
</div>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<!-- Pagination -->
{% if pagination.total_pages > 1 %}
<nav aria-label="Pagination">
<ul class="pagination justify-content-center">
{% if pagination.has_prev %}
<li class="page-item">
<a class="page-link" href="?page={{ pagination.prev_page }}">Precedente</a>
</li>
{% endif %}
{% for page_num in range(1, pagination.total_pages + 1) %}
{% if page_num == pagination.page %}
<li class="page-item active">
<span class="page-link">{{ page_num }}</span>
</li>
{% elif page_num <= 3 or page_num > pagination.total_pages - 3 or (page_num >= pagination.page - 1 and page_num <= pagination.page + 1) %}
<li class="page-item">
<a class="page-link" href="?page={{ page_num }}">{{ page_num }}</a>
</li>
{% elif page_num == 4 or page_num == pagination.total_pages - 3 %}
<li class="page-item disabled">
<span class="page-link">...</span>
</li>
{% endif %}
{% endfor %}
{% if pagination.has_next %}
<li class="page-item">
<a class="page-link" href="?page={{ pagination.next_page }}">Successivo</a>
</li>
{% endif %}
</ul>
</nav>
{% endif %}
{% else %}
<div class="text-center py-5">
<i class="bi bi-folder2-open display-1 text-muted"></i>
<h4 class="mt-3">Nessun progetto ancora</h4>
<p class="text-muted">Inizia creando il tuo primo progetto</p>
<a href="{{ url_for('dashboard.new_project') }}" class="btn btn-primary">
<i class="bi bi-plus"></i> Crea Primo Progetto
</a>
</div>
{% endif %}
</div>
</div>
{% endblock %}