changes
This commit is contained in:
+38
-4
@@ -3236,13 +3236,48 @@ def admin_invoices():
|
||||
}
|
||||
)
|
||||
flash("Rechnung angelegt.", "success")
|
||||
|
||||
# NEU HINZUGEFÜGT: Die Logik für das Update (Aktualisieren) Formular
|
||||
elif action == "update" and invoice_id:
|
||||
invoice_number = _sanitize_text(request.form.get("invoice_number") or "", 120)
|
||||
period = _sanitize_text(request.form.get("period") or "", 20)
|
||||
due_date = _sanitize_text(request.form.get("due_date") or "", 20)
|
||||
status = _sanitize_text(request.form.get("status") or "Zu prüfen", 40)
|
||||
amount_text = _sanitize_text(request.form.get("amount_eur") or "0", 20)
|
||||
|
||||
try:
|
||||
amount = float(amount_text.replace(',', '.'))
|
||||
except ValueError:
|
||||
amount = 0.0
|
||||
|
||||
update_data = {
|
||||
"invoice_number": invoice_number,
|
||||
"period": period,
|
||||
"amount_eur": amount,
|
||||
"status": status,
|
||||
"due_date": due_date
|
||||
}
|
||||
|
||||
# PDF nur überschreiben, wenn auch ein neues hochgeladen wurde
|
||||
pdf_file = request.files.get("invoice_pdf")
|
||||
if pdf_file and pdf_file.filename:
|
||||
pdf_path = _save_invoice_pdf(pdf_file, invoice_number)
|
||||
if pdf_path:
|
||||
update_data["pdf_path"] = pdf_path
|
||||
|
||||
col.update_one(
|
||||
{"_id": ObjectId(invoice_id)},
|
||||
{"$set": update_data}
|
||||
)
|
||||
flash("Rechnung erfolgreich aktualisiert.", "success")
|
||||
|
||||
elif action == "delete" and invoice_id:
|
||||
col.delete_one({"_id": ObjectId(invoice_id)})
|
||||
flash("Rechnung gelöscht.", "success")
|
||||
else:
|
||||
flash("Ungültige Aktion.", "error")
|
||||
except Exception:
|
||||
except Exception as e:
|
||||
print(f"Fehler bei admin_invoices: {e}") # Ins Log schreiben
|
||||
flash("Rechnungsverwaltung fehlgeschlagen.", "error")
|
||||
finally:
|
||||
if client:
|
||||
@@ -3268,7 +3303,7 @@ def admin_invoices():
|
||||
if not isinstance(item.get("booking_data"), dict):
|
||||
item["booking_data"] = {}
|
||||
|
||||
except PyMongoError:
|
||||
except Exception: # Geändert von PyMongoError zu general Exception für Sicherheit
|
||||
flash("Rechnungen konnten nicht geladen werden.", "error")
|
||||
finally:
|
||||
if client:
|
||||
@@ -3284,7 +3319,7 @@ def admin_invoices():
|
||||
if not isinstance(prov.get("booking_data"), dict):
|
||||
prov["booking_data"] = {}
|
||||
|
||||
except PyMongoError:
|
||||
except Exception:
|
||||
flash("Instanz-Anfragen konnten nicht geladen werden.", "error")
|
||||
finally:
|
||||
if 'req_client' in locals() and req_client:
|
||||
@@ -3293,7 +3328,6 @@ def admin_invoices():
|
||||
users = _list_users_for_admin()
|
||||
return render_template("admin_invoices.html", invoices=invoices, users=users, provision_requests=instance_requests)
|
||||
|
||||
|
||||
@app.route('/datenschutz')
|
||||
def datenschutz():
|
||||
return render_template("datenschutz.html")
|
||||
|
||||
Reference in New Issue
Block a user