dev #1
@@ -204,33 +204,33 @@ 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
|
||||
device = conn.execute("SELECT name, switch_hostname FROM devices WHERE mac=?", (old_mac,)).fetchone()
|
||||
# --- 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!")
|
||||
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
|
||||
SET switch_hostname=?
|
||||
WHERE mac=?
|
||||
""", (switch_hostname, old_mac))
|
||||
conn.commit()
|
||||
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'))
|
||||
|
||||
old_switch = device['switch_hostname'] or "unbekannt"
|
||||
device_name = device['name']
|
||||
|
||||
try:
|
||||
conn.execute("""
|
||||
UPDATE devices
|
||||
SET switch_hostname=?
|
||||
WHERE mac=?
|
||||
""", (switch_hostname, old_mac))
|
||||
conn.commit()
|
||||
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'))
|
||||
|
||||
if not all([old_mac, mac, rpi_ip, port, name]):
|
||||
flash("Alle Felder müssen ausgefüllt sein!")
|
||||
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'))
|
||||
|
||||
# Prüfen auf doppelte IP außer das aktuelle Gerät
|
||||
ip_device = conn.execute("SELECT name FROM devices WHERE rpi_ip=? AND mac<>?", (rpi_ip, old_mac)).fetchone()
|
||||
|
||||
Reference in New Issue
Block a user