save ok in log

This commit is contained in:
Cayo Puigdefabregas 2022-05-18 12:47:23 +02:00
parent c0abfd6f0b
commit 112e6bd01a
1 changed files with 16 additions and 1 deletions

View File

@ -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