srv/poe_manager/app.py aktualisiert
This commit is contained in:
@@ -255,22 +255,6 @@ def devices():
|
||||
except sqlite3.IntegrityError:
|
||||
flash("Fehler beim Aktualisieren des Geräts!")
|
||||
|
||||
# -----------------------
|
||||
# Gerät aktivieren/deaktivieren
|
||||
# -----------------------
|
||||
elif 'toggle_device' in request.form:
|
||||
mac = request.form.get('toggle_device')
|
||||
device = conn.execute("SELECT is_active, name FROM devices WHERE mac=?", (mac,)).fetchone()
|
||||
if device:
|
||||
new_status = 0 if device['is_active'] else 1
|
||||
conn.execute("UPDATE devices SET is_active=? WHERE mac=?", (new_status, mac))
|
||||
conn.commit()
|
||||
status_text = "deaktiviert" if new_status == 0 else "aktiviert"
|
||||
flash(f"Gerät '{device['name']}' wurde {status_text}.")
|
||||
else:
|
||||
flash("Gerät nicht gefunden!")
|
||||
return redirect(url_for('devices'))
|
||||
|
||||
# -----------------------
|
||||
# Gerät löschen
|
||||
# -----------------------
|
||||
@@ -326,7 +310,7 @@ def toggle_device(mac):
|
||||
conn.close()
|
||||
|
||||
status_text = "deaktiviert" if new_status == 0 else "aktiviert"
|
||||
flash(f"Gerät '{device['name']}' wurde {status_text}.")
|
||||
flash(f"Gerät {device['name']} wurde {status_text}.")
|
||||
return redirect(url_for('devices'))
|
||||
|
||||
@app.route('/switches', methods=['GET', 'POST'])
|
||||
|
||||
Reference in New Issue
Block a user