przeliczenie wielkosci plikow
This commit is contained in:
21
app.py
21
app.py
@@ -2027,6 +2027,27 @@ def crop_receipt():
|
||||
return jsonify(success=False, error=str(e))
|
||||
|
||||
|
||||
@app.route("/admin/recalculate_filesizes")
|
||||
@login_required
|
||||
@admin_required
|
||||
def recalculate_filesizes():
|
||||
updated = 0
|
||||
not_found = 0
|
||||
|
||||
receipts = Receipt.query.all()
|
||||
for r in receipts:
|
||||
filepath = os.path.join(app.config["UPLOAD_FOLDER"], r.filename)
|
||||
if os.path.exists(filepath):
|
||||
r.filesize = os.path.getsize(filepath)
|
||||
updated += 1
|
||||
else:
|
||||
not_found += 1
|
||||
|
||||
db.session.commit()
|
||||
flash(f"Zaktualizowano rozmiar dla {updated} plików. Nie znaleziono: {not_found}.", "success")
|
||||
return redirect(url_for("admin_receipts", id="all"))
|
||||
|
||||
|
||||
@app.route("/healthcheck")
|
||||
def healthcheck():
|
||||
header_token = request.headers.get("X-Internal-Check")
|
||||
|
@@ -4,7 +4,12 @@
|
||||
|
||||
<div class="d-flex justify-content-between align-items-center flex-wrap mb-4">
|
||||
<h2 class="mb-2">📸 Wszystkie paragony</h2>
|
||||
<a href="/admin" class="btn btn-outline-secondary">← Powrót do panelu</a>
|
||||
<div>
|
||||
<a href="{{ url_for('recalculate_filesizes') }}" class="btn btn-sm btn-outline-primary me-2">
|
||||
🔄 Przelicz rozmiary plików
|
||||
</a>
|
||||
<a href="/admin" class="btn btn-outline-secondary">← Powrót do panelu</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card bg-dark text-white mb-5">
|
||||
|
Reference in New Issue
Block a user