diff options
author | Frederick Yin <fkfd@fkfd.me> | 2022-02-06 16:44:18 +0800 |
---|---|---|
committer | Frederick Yin <fkfd@fkfd.me> | 2022-02-06 16:44:18 +0800 |
commit | 425edff4ff3d312a879258ca7387d53498ba94ef (patch) | |
tree | d7ba61cc98d5091b6ffffd3f1a9401cddc8c2cbe /jimbrella/admin.py | |
parent | 7a110edc2529111077351c31f4414849de5515d3 (diff) |
Adapt to new AdminLog interface
Diffstat (limited to 'jimbrella/admin.py')
-rw-r--r-- | jimbrella/admin.py | 19 |
1 files changed, 3 insertions, 16 deletions
diff --git a/jimbrella/admin.py b/jimbrella/admin.py index b150e3d..9d7d98b 100644 --- a/jimbrella/admin.py +++ b/jimbrella/admin.py @@ -12,7 +12,7 @@ from .utils import human_datetime, human_timedelta, CST bp = Blueprint("admin", __name__, url_prefix="/admin") db = Umbrellas(config.get("general", "db_path")) users = Users(config.get("general", "db_path")) -admin_log = AdminLog(config.get("logging", "admin_log_path")) +admin_log = AdminLog(config.get("general", "db_path")) @bp.before_request @@ -115,7 +115,7 @@ def umbrellas_edit(): data[key] = request.form.get(key) try: - diff = db.update(data) + db.admin_modify(session["username"], data) except UmbrellaValueError as e: # invalid field is in `e.message`. return redirect( @@ -126,23 +126,10 @@ def umbrellas_edit(): except UmbrellaNotFoundError: abort(400) - for column, value_pair in diff.items(): - past, new = value_pair - admin_log.log( - "ADMIN_MODIFY_DB", - { - "admin_name": session["username"], - "id": data["id"], - "column": column, - "past_value": past, - "new_value": new, - }, - ) - return redirect(url_for("admin.umbrellas")) @bp.route("/logs") def logs(): logs = admin_log.read() - return render_template("admin/logs.html", logs=logs) + return render_template("admin/admin_logs.html", logs=logs) |