srv/poe_manager/app.py aktualisiert
This commit is contained in:
@@ -166,18 +166,18 @@ def devices():
|
|||||||
flash("Alle Felder müssen ausgefüllt sein!")
|
flash("Alle Felder müssen ausgefüllt sein!")
|
||||||
return redirect(url_for('devices'))
|
return redirect(url_for('devices'))
|
||||||
|
|
||||||
# Prüfen auf doppelte MAC
|
|
||||||
mac_device = conn.execute("SELECT name FROM devices WHERE mac=?", (mac,)).fetchone()
|
|
||||||
if mac_device:
|
|
||||||
flash(f"MAC-Adresse existiert bereits für Gerät '{mac_device['name']}'!")
|
|
||||||
return redirect(url_for('devices'))
|
|
||||||
|
|
||||||
# Prüfen auf doppelte IP
|
# Prüfen auf doppelte IP
|
||||||
ip_device = conn.execute("SELECT name FROM devices WHERE rpi_ip=?", (rpi_ip,)).fetchone()
|
ip_device = conn.execute("SELECT name FROM devices WHERE rpi_ip=?", (rpi_ip,)).fetchone()
|
||||||
if ip_device:
|
if ip_device:
|
||||||
flash(f"IP-Adresse existiert bereits für Gerät '{ip_device['name']}'!")
|
flash(f"IP-Adresse existiert bereits für Gerät '{ip_device['name']}'!")
|
||||||
return redirect(url_for('devices'))
|
return redirect(url_for('devices'))
|
||||||
|
|
||||||
|
# Prüfen auf doppelte MAC
|
||||||
|
mac_device = conn.execute("SELECT name FROM devices WHERE mac=?", (mac,)).fetchone()
|
||||||
|
if mac_device:
|
||||||
|
flash(f"MAC-Adresse existiert bereits für Gerät '{mac_device['name']}'!")
|
||||||
|
return redirect(url_for('devices'))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
conn.execute("""
|
conn.execute("""
|
||||||
INSERT INTO devices (mac, rpi_ip, port, name, switch_hostname, is_active)
|
INSERT INTO devices (mac, rpi_ip, port, name, switch_hostname, is_active)
|
||||||
@@ -208,18 +208,18 @@ def devices():
|
|||||||
flash("Alle Felder müssen ausgefüllt sein!")
|
flash("Alle Felder müssen ausgefüllt sein!")
|
||||||
return redirect(url_for('devices'))
|
return redirect(url_for('devices'))
|
||||||
|
|
||||||
# Prüfen auf doppelte MAC außer das aktuelle Gerät
|
|
||||||
mac_device = conn.execute("SELECT name FROM devices WHERE mac=? AND mac<>?", (mac, old_mac)).fetchone()
|
|
||||||
if mac_device:
|
|
||||||
flash(f"MAC-Adresse existiert bereits für Gerät '{mac_device['name']}'!")
|
|
||||||
return redirect(url_for('devices'))
|
|
||||||
|
|
||||||
# Prüfen auf doppelte IP außer das aktuelle Gerät
|
# 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()
|
ip_device = conn.execute("SELECT name FROM devices WHERE rpi_ip=? AND mac<>?", (rpi_ip, old_mac)).fetchone()
|
||||||
if ip_device:
|
if ip_device:
|
||||||
flash(f"IP-Adresse existiert bereits für Gerät '{ip_device['name']}'!")
|
flash(f"IP-Adresse existiert bereits für Gerät '{ip_device['name']}'!")
|
||||||
return redirect(url_for('devices'))
|
return redirect(url_for('devices'))
|
||||||
|
|
||||||
|
# Prüfen auf doppelte MAC außer das aktuelle Gerät
|
||||||
|
mac_device = conn.execute("SELECT name FROM devices WHERE mac=? AND mac<>?", (mac, old_mac)).fetchone()
|
||||||
|
if mac_device:
|
||||||
|
flash(f"MAC-Adresse existiert bereits für Gerät '{mac_device['name']}'!")
|
||||||
|
return redirect(url_for('devices'))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
conn.execute("""
|
conn.execute("""
|
||||||
UPDATE devices
|
UPDATE devices
|
||||||
|
|||||||
Reference in New Issue
Block a user