paginacja paragonow

This commit is contained in:
Mateusz Gruszczyński
2025-08-12 23:18:08 +02:00
parent a224ec1c2a
commit 1e04039387
2 changed files with 18 additions and 10 deletions

8
app.py
View File

@@ -52,7 +52,7 @@ from functools import wraps
from flask_session import Session
from types import SimpleNamespace
from pdf2image import convert_from_bytes
from urllib.parse import urlencode
# OCR
import pytesseract
@@ -2435,7 +2435,8 @@ def admin_receipts(id):
return redirect(url_for("admin_panel"))
args_without_page = request.args.to_dict()
args_without_page.pop('page', None)
args_without_page.pop("page", None)
query_string = urlencode(args_without_page)
return render_template(
"admin/receipts.html",
@@ -2445,10 +2446,11 @@ def admin_receipts(id):
page=page,
total_pages=total_pages,
id=id,
args_without_page=args_without_page,
query_string=query_string
)
@app.route("/admin/rotate_receipt/<int:receipt_id>")
@login_required
@admin_required

View File

@@ -69,29 +69,35 @@
<nav aria-label="Nawigacja stron">
<ul class="pagination justify-content-center">
{# Link do poprzedniej strony #}
{# Poprzednia strona #}
<li class="page-item {% if page <= 1 %}disabled{% endif %}">
<a class="page-link" href="{{ url_for('admin_receipts', id=id, **args_without_page, page=page-1) }}" tabindex="-1">
<a class="page-link"
href="{{ url_for('admin_receipts', id=id) }}?{{ query_string }}{% if query_string %}&{% endif %}page={{ page-1 }}">
« Poprzednia
</a>
</li>
{# Linki do numerów stron #}
{# Numery stron #}
{% for p in range(1, total_pages + 1) %}
<li class="page-item {% if p == page %}active{% endif %}">
<a class="page-link" href="{{ url_for('admin_receipts', id=id, **args_without_page, page=p) }}">{{ p }}</a>
<a class="page-link"
href="{{ url_for('admin_receipts', id=id) }}?{{ query_string }}{% if query_string %}&{% endif %}page={{ p }}">
{{ p }}
</a>
</li>
{% endfor %}
{# Link do następnej strony #}
{# Następna strona #}
<li class="page-item {% if page >= total_pages %}disabled{% endif %}">
<a class="page-link" href="{{ url_for('admin_receipts', id=id, **args_without_page, page=page+1) }}">Następna »</a>
<a class="page-link"
href="{{ url_for('admin_receipts', id=id) }}?{{ query_string }}{% if query_string %}&{% endif %}page={{ page+1 }}">
Następna »
</a>
</li>
</ul>
</nav>
{% if orphan_files and request.path.endswith('/all') %}
<hr class="my-4">
<h4 class="mt-3 mb-2 text-warning">Znalezione nieprzypisane pliki ({{ orphan_files_count }})</h4>