This commit is contained in:
@@ -2069,32 +2069,6 @@ def tablets_speichern(tablet_id):
|
||||
name = (request.form.get("name") or "").strip()[:60]
|
||||
ziel_typ = request.form.get("ziel_typ") or ""
|
||||
maschine_id = request.form.get("maschine_id", type=int)
|
||||
ersetzt_id = request.form.get("ersetzt_id", type=int)
|
||||
|
||||
if ersetzt_id and ersetzt_id != tablet_id:
|
||||
# Neues Gerät (z.B. nach gelöschten Browserdaten) übernimmt Name und
|
||||
# Zuordnung eines alten Eintrags; der alte Eintrag wird entfernt.
|
||||
with db.get_cursor() as cur:
|
||||
cur.execute('SELECT * FROM "Tablets" WHERE id = %s', (ersetzt_id,))
|
||||
alt = cur.fetchone()
|
||||
cur.execute('SELECT * FROM "Tablets" WHERE id = %s', (tablet_id,))
|
||||
neu = cur.fetchone()
|
||||
if not alt or not neu:
|
||||
abort(404)
|
||||
cur.execute(
|
||||
'UPDATE "Tablets" SET name = %s, ziel_typ = %s, maschine_id = %s WHERE id = %s RETURNING *',
|
||||
(alt["name"], alt["ziel_typ"], alt["maschine_id"], tablet_id),
|
||||
)
|
||||
neu = cur.fetchone()
|
||||
ziel = _ziel_text(cur, alt["ziel_typ"], alt["maschine_id"])
|
||||
tablet_log(
|
||||
cur, "Eintrag ersetzt",
|
||||
f"Übernimmt Name \"{alt['name']}\" und Zuordnung ({ziel}) von Tablet {_tablet_kurzkennung(alt['kennung'])}",
|
||||
neu,
|
||||
)
|
||||
tablet_log(cur, "Entfernt", f"Ersetzt durch Tablet {_tablet_kurzkennung(neu['kennung'])} (\"{neu['name']}\")", alt)
|
||||
cur.execute('DELETE FROM "Tablets" WHERE id = %s', (ersetzt_id,))
|
||||
return _zur_tablet_zeile(tablet_id)
|
||||
|
||||
if ziel_typ and ziel_typ not in TABLET_ZIELE:
|
||||
return _tablets_seite(error="Ungültiges Ziel.", fehler_id=tablet_id), 400
|
||||
|
||||
Reference in New Issue
Block a user