srv/poe_manager/app.py aktualisiert

This commit is contained in:
2025-10-07 22:59:00 +02:00
parent 0fd53990e6
commit cce1de034a

View File

@@ -207,6 +207,15 @@ def devices():
# --- 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
device = conn.execute("SELECT name, switch_hostname FROM devices WHERE mac=?", (old_mac,)).fetchone()
if not device:
flash("Gerät nicht gefunden!")
return redirect(url_for('devices'))
old_switch = device['switch_hostname'] or "unbekannt"
device_name = device['name']
try:
conn.execute("""
UPDATE devices
@@ -214,7 +223,7 @@ def devices():
WHERE mac=?
""", (switch_hostname, old_mac))
conn.commit()
flash("Switch wurde geändert.")
flash(f"Switch von '{device_name}' geändert: {old_switch}{switch_hostname}")
except sqlite3.IntegrityError:
flash("Fehler beim Ändern des Switch!")
return redirect(url_for('devices'))