From cd94d032e3d50aa1ca44aece7d0e2cb5ca148899 Mon Sep 17 00:00:00 2001 From: boyska Date: Mon, 17 Jan 2022 00:48:44 +0100 Subject: [PATCH] make web UI compatible with multiDB --- larigira/dbadmin/__init__.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/larigira/dbadmin/__init__.py b/larigira/dbadmin/__init__.py index 319420a..494337e 100644 --- a/larigira/dbadmin/__init__.py +++ b/larigira/dbadmin/__init__.py @@ -110,7 +110,7 @@ def addtime(): return render_template("add_time.html", kinds=kinds, info=info) -@db.route("/edit/time/", methods=["GET", "POST"]) +@db.route("/edit/time/", methods=["GET", "POST"]) def edit_time(alarmid): model = get_model() timespec = model.get_alarm_by_id(alarmid) @@ -197,7 +197,7 @@ def addaudio_kind(kind): ) -@db.route("/edit/audio/", methods=["GET", "POST"]) +@db.route("/edit/audio/", methods=["GET", "POST"]) def edit_audio(actionid): model = get_model() audiospec = model.get_action_by_id(actionid) @@ -223,7 +223,7 @@ def edit_audio(actionid): @db.route("/edit/event/") def edit_event(alarmid): model = current_app.larigira.controller.monitor.model - alarm = model.get_alarm_by_id(int(alarmid)) + alarm = model.get_alarm_by_id(alarmid) if alarm is None: abort(404) allactions = model.get_all_actions() @@ -245,16 +245,16 @@ def change_actions(alarmid): new_actions = [] model = current_app.larigira.controller.monitor.model ret = model.update_alarm( - int(alarmid), new_fields={"actions": [int(a) for a in new_actions]} + alarmid, new_fields={"actions": [a for a in new_actions]} ) return jsonify(dict(updated=alarmid, ret=ret)) -@db.route("/api/alarm//delete", methods=["POST"]) +@db.route("/api/alarm//delete", methods=["POST"]) def delete_alarm(alarmid): model = current_app.larigira.controller.monitor.model try: - alarm = model.get_alarm_by_id(int(alarmid)) + alarm = model.get_alarm_by_id(alarmid) print(alarm["nick"]) model.delete_alarm(alarmid) except KeyError: