From 59c3ef23de9f1887a0428d9ee49bca6e4d7743aa Mon Sep 17 00:00:00 2001 From: alexandre Date: Wed, 22 Mar 2023 11:03:13 +0100 Subject: [PATCH 1/2] grabUser added --- modules/entry/back/models/buy.json | 5 +++-- modules/entry/back/models/entry.json | 3 ++- modules/item/back/models/item.json | 5 +++-- modules/route/back/models/route.json | 3 ++- modules/ticket/back/models/sale.json | 3 ++- modules/ticket/back/models/ticket.json | 7 ++++--- modules/travel/back/models/travel.json | 3 ++- 7 files changed, 18 insertions(+), 11 deletions(-) diff --git a/modules/entry/back/models/buy.json b/modules/entry/back/models/buy.json index 8e36d0eef..de2ddffd6 100644 --- a/modules/entry/back/models/buy.json +++ b/modules/entry/back/models/buy.json @@ -3,7 +3,8 @@ "base": "Loggable", "log": { "model": "EntryLog", - "relation": "entry" + "relation": "entry", + "grabUser": true }, "options": { "mysql": { @@ -70,4 +71,4 @@ "foreignKey": "packageFk" } } -} \ No newline at end of file +} diff --git a/modules/entry/back/models/entry.json b/modules/entry/back/models/entry.json index d9b7c52df..48b4d1be0 100644 --- a/modules/entry/back/models/entry.json +++ b/modules/entry/back/models/entry.json @@ -2,7 +2,8 @@ "name": "Entry", "base": "Loggable", "log": { - "model":"EntryLog" + "model":"EntryLog", + "grabUser": true }, "options": { "mysql": { diff --git a/modules/item/back/models/item.json b/modules/item/back/models/item.json index 2f58c30a9..dc38a44e6 100644 --- a/modules/item/back/models/item.json +++ b/modules/item/back/models/item.json @@ -3,7 +3,8 @@ "base": "Loggable", "log": { "model": "ItemLog", - "showField": "id" + "showField": "id", + "grabUser": true }, "options": { "mysql": { @@ -214,4 +215,4 @@ } } } -} \ No newline at end of file +} diff --git a/modules/route/back/models/route.json b/modules/route/back/models/route.json index 12b9785db..3b12f4ee6 100644 --- a/modules/route/back/models/route.json +++ b/modules/route/back/models/route.json @@ -2,7 +2,8 @@ "name": "Route", "base": "Loggable", "log": { - "model":"RouteLog" + "model":"RouteLog", + "grabUser": true }, "options": { "mysql": { diff --git a/modules/ticket/back/models/sale.json b/modules/ticket/back/models/sale.json index b30954ad1..b1f70f5e2 100644 --- a/modules/ticket/back/models/sale.json +++ b/modules/ticket/back/models/sale.json @@ -4,7 +4,8 @@ "log": { "model": "TicketLog", "relation": "ticket", - "showField": "concept" + "showField": "concept", + "grabUser": true }, "options": { "mysql": { diff --git a/modules/ticket/back/models/ticket.json b/modules/ticket/back/models/ticket.json index 09b01d213..89ebde85d 100644 --- a/modules/ticket/back/models/ticket.json +++ b/modules/ticket/back/models/ticket.json @@ -3,7 +3,8 @@ "base": "Loggable", "log": { "model":"TicketLog", - "showField": "id" + "showField": "id", + "grabUser": true }, "options": { "mysql": { @@ -36,7 +37,7 @@ "type": "number" }, "updated": { - "type": "date", + "type": "date", "mysql": { "columnName": "created" } @@ -136,4 +137,4 @@ "foreignKey": "zoneFk" } } -} \ No newline at end of file +} diff --git a/modules/travel/back/models/travel.json b/modules/travel/back/models/travel.json index c20b7b0bf..7dd9f5bba 100644 --- a/modules/travel/back/models/travel.json +++ b/modules/travel/back/models/travel.json @@ -3,7 +3,8 @@ "base": "Loggable", "log": { "model":"TravelLog", - "showField": "ref" + "showField": "ref", + "grabUser": true }, "options": { "mysql": { From 81472a5e50b63758cbecac683ef2470275ed8566 Mon Sep 17 00:00:00 2001 From: alexandre Date: Wed, 22 Mar 2023 11:36:28 +0100 Subject: [PATCH 2/2] removed duplicated log --- modules/ticket/back/methods/ticket/new.js | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/modules/ticket/back/methods/ticket/new.js b/modules/ticket/back/methods/ticket/new.js index e6048421e..e7e4cd01b 100644 --- a/modules/ticket/back/methods/ticket/new.js +++ b/modules/ticket/back/methods/ticket/new.js @@ -126,19 +126,6 @@ module.exports = Self => { ], myOptions); const ticket = await models.Ticket.findById(result[1][0].newTicketId, null, myOptions); - const cleanInstance = JSON.parse(JSON.stringify(ticket)); - - const logRecord = { - originFk: cleanInstance.id, - userFk: myUserId, - action: 'insert', - changedModel: 'Ticket', - changedModelId: cleanInstance.id, - oldInstance: {}, - newInstance: cleanInstance - }; - - await models.TicketLog.create(logRecord, myOptions); if (tx) await tx.commit();