From 0fd53990e6fe0cd05359e2a5209027a322dda8ed Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Tue, 7 Oct 2025 22:53:14 +0200 Subject: [PATCH] srv/poe_manager/app.py aktualisiert --- srv/poe_manager/app.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/srv/poe_manager/app.py b/srv/poe_manager/app.py index 4559db0..1f071d6 100644 --- a/srv/poe_manager/app.py +++ b/srv/poe_manager/app.py @@ -204,6 +204,21 @@ def devices(): switch_hostname = request.form.get('switch_hostname') or None is_active = 1 if 'is_active' in request.form else 0 + # --- Prüfen, ob es sich um eine Switch-Änderung handelt --- + if mac is None and rpi_ip is None and port is None and name is None and switch_hostname: + # Nur den Switch ändern + try: + conn.execute(""" + UPDATE devices + SET switch_hostname=? + WHERE mac=? + """, (switch_hostname, old_mac)) + conn.commit() + flash("Switch wurde geändert.") + except sqlite3.IntegrityError: + flash("Fehler beim Ändern des Switch!") + return redirect(url_for('devices')) + if not all([old_mac, mac, rpi_ip, port, name]): flash("Alle Felder müssen ausgefüllt sein!") return redirect(url_for('devices'))