From 112e6bd01a2dca4828e10f277fff797836bdbcb8 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Wed, 18 May 2022 12:47:23 +0200 Subject: [PATCH] save ok in log --- ereuse_devicehub/api/views.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/ereuse_devicehub/api/views.py b/ereuse_devicehub/api/views.py index 9ab5d32c..1385a78d 100644 --- a/ereuse_devicehub/api/views.py +++ b/ereuse_devicehub/api/views.py @@ -59,6 +59,16 @@ class InventoryView(LoginMixin, SnapshotMixin): snapshot = self.build() db.session.add(snapshot) + + snap_log = SnapshotsLog( + description='Ok', + snapshot_uuid=snapshot.uuid, + severity=Severity.Info, + sid=snapshot.sid, + version=snapshot.version, + ) + snap_log.save() + db.session().final_flush() db.session.commit() self.response = jsonify( @@ -80,8 +90,13 @@ class InventoryView(LoginMixin, SnapshotMixin): txt = "{}".format(err) uuid = snapshot_json.get('uuid') sid = snapshot_json.get('sid') + version = snapshot_json.get('version') error = SnapshotsLog( - description=txt, snapshot_uuid=uuid, severity=Severity.Error, sid=sid + description=txt, + snapshot_uuid=uuid, + severity=Severity.Error, + sid=sid, + version=version, ) error.save(commit=True) # raise err