wizualne
This commit is contained in:
34
app.py
34
app.py
@@ -2847,15 +2847,27 @@ def delete_user(user_id):
|
||||
return redirect(url_for("list_users"))
|
||||
|
||||
|
||||
@app.route("/admin/receipts", defaults={'id': 'all'})
|
||||
@app.route("/admin/receipts/<id>")
|
||||
@app.route("/admin/receipts", methods=["GET"])
|
||||
@app.route("/admin/receipts/<int:list_id>", methods=["GET"])
|
||||
@login_required
|
||||
@admin_required
|
||||
def admin_receipts(id):
|
||||
def admin_receipts(list_id=None):
|
||||
try:
|
||||
page, per_page = get_page_args(default_per_page=24, max_per_page=200)
|
||||
|
||||
if id == "all":
|
||||
if list_id is not None:
|
||||
all_receipts = (
|
||||
Receipt.query.options(joinedload(Receipt.uploaded_by_user))
|
||||
.filter_by(list_id=list_id)
|
||||
.order_by(Receipt.uploaded_at.desc())
|
||||
.all()
|
||||
)
|
||||
receipts_paginated, total_items, total_pages = paginate_items(
|
||||
all_receipts, page, per_page
|
||||
)
|
||||
orphan_files = []
|
||||
id = list_id
|
||||
else:
|
||||
all_filenames = {
|
||||
r.filename for r in Receipt.query.with_entities(Receipt.filename).all()
|
||||
}
|
||||
@@ -2868,6 +2880,7 @@ def admin_receipts(id):
|
||||
|
||||
receipts_paginated = pagination.items
|
||||
total_pages = pagination.pages
|
||||
id = "all"
|
||||
|
||||
upload_folder = app.config["UPLOAD_FOLDER"]
|
||||
files_on_disk = set(os.listdir(upload_folder))
|
||||
@@ -2878,25 +2891,12 @@ def admin_receipts(id):
|
||||
and f not in all_filenames
|
||||
and f.startswith("list_")
|
||||
]
|
||||
else:
|
||||
list_id = int(id)
|
||||
all_receipts = (
|
||||
Receipt.query.options(joinedload(Receipt.uploaded_by_user))
|
||||
.filter_by(list_id=list_id)
|
||||
.order_by(Receipt.uploaded_at.desc())
|
||||
.all()
|
||||
)
|
||||
receipts_paginated, total_items, total_pages = paginate_items(
|
||||
all_receipts, page, per_page
|
||||
)
|
||||
orphan_files = []
|
||||
|
||||
except ValueError:
|
||||
flash("Nieprawidłowe ID listy.", "danger")
|
||||
return redirect(url_for("admin_panel"))
|
||||
|
||||
total_filesize = db.session.query(func.sum(Receipt.filesize)).scalar() or 0
|
||||
|
||||
page_filesize = sum(r.filesize or 0 for r in receipts_paginated)
|
||||
|
||||
query_string = urlencode({k: v for k, v in request.args.items() if k != "page"})
|
||||
|
@@ -11,11 +11,10 @@
|
||||
<div class="card-body p-2">
|
||||
<div class="d-flex flex-wrap gap-2">
|
||||
<a href="{{ url_for('list_users') }}" class="btn btn-outline-light btn-sm">👥 Użytkownicy</a>
|
||||
<a href="{{ url_for('admin_receipts', id='all') }}" class="btn btn-outline-light btn-sm">📸 Paragony</a>
|
||||
<a href="{{ url_for('admin_receipts') }}" class="btn btn-outline-light btn-sm">📸 Paragony</a>
|
||||
<a href="{{ url_for('list_products') }}" class="btn btn-outline-light btn-sm">🛍️ Produkty</a>
|
||||
<a href="{{ url_for('admin_mass_edit_categories') }}" class="btn btn-outline-light btn-sm">🗂 Kategorie</a>
|
||||
<a href="{{ url_for('admin_lists_access') }}" class="btn btn-outline-light btn-sm">🔐 Uprawnienia list</a>
|
||||
|
||||
<a href="{{ url_for('admin_lists_access') }}" class="btn btn-outline-light btn-sm">🔐 Uprawnienia</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -219,7 +218,7 @@
|
||||
— <strong>{{ month_str|replace('-', ' / ') }}</strong>
|
||||
{% endif %}
|
||||
</h3>
|
||||
<form method="post" action="{{ url_for('admin_delete_list') }}">
|
||||
<form method="post" action="{{ url_for('admin_delete_list') }}" onsubmit="return confirm('Na pewno usunąć tę listę?')" class="d-inline">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-dark align-middle sortable">
|
||||
<thead>
|
||||
@@ -301,11 +300,6 @@
|
||||
title="Podgląd produktów">
|
||||
👁️
|
||||
</button>
|
||||
<form method="post" action="{{ url_for('admin_delete_list') }}"
|
||||
onsubmit="return confirm('Na pewno usunąć tę listę?')" class="d-inline">
|
||||
<input type="hidden" name="single_list_id" value="{{ l.id }}">
|
||||
<button type="submit" class="btn btn-sm btn-outline-light" title="Usuń">🗑️</button>
|
||||
</form>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
Reference in New Issue
Block a user