[Fix] Transaction log corrections (#6693)

* Transaction log corrections + improvements

* Remove unused import

* Timestamp format

* Add system manager to permissions
This commit is contained in:
Charles-Henri Decultot 2019-01-02 04:40:50 +01:00 committed by Rushabh Mehta
parent 8e854fa494
commit 06ea7499ab
6 changed files with 36 additions and 11 deletions

View file

@ -0,0 +1,16 @@
# Transaction Log Changelog
## v1.0.0
Initial version
The line hash summarizes:
- The index of the row
- The timestamp
- The document raw data
The chain hash summarizes:
- The previous line hash
- The current line hash
## v1.0.1
Modification of the timestamp fieldtype from "Time" to "Datetime"

View file

@ -1,5 +1,6 @@
{
"allow_copy": 0,
"allow_events_in_timeline": 0,
"allow_guest_to_view": 0,
"allow_import": 0,
"allow_rename": 0,
@ -178,7 +179,7 @@
"collapsible": 0,
"columns": 0,
"fieldname": "timestamp",
"fieldtype": "Time",
"fieldtype": "Datetime",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
@ -436,7 +437,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2018-09-21 08:49:07.915376",
"modified": "2018-12-27 15:22:34.533766",
"modified_by": "Administrator",
"module": "Core",
"name": "Transaction Log",

View file

@ -6,14 +6,14 @@ from __future__ import unicode_literals
import frappe
from frappe import _
from frappe.model.document import Document
from frappe.utils import now, cint
from frappe.utils import cint, now_datetime
import hashlib
class TransactionLog(Document):
def before_insert(self):
index = get_current_index()
self.row_index = index
self.timestamp = now()
self.timestamp = now_datetime()
if index != 1:
prev_hash = frappe.db.sql(
"SELECT chaining_hash FROM `tabTransaction Log` WHERE row_index = {0}".format(index - 1))
@ -25,7 +25,7 @@ class TransactionLog(Document):
self.previous_hash = self.hash_line()
self.transaction_hash = self.hash_line()
self.chaining_hash = self.hash_chain()
self.checksum_version = "v1.0.0"
self.checksum_version = "v1.0.1"
def hash_line(self):
sha = hashlib.sha256()

View file

@ -1,7 +1,11 @@
// Copyright (c) 2016, Frappe Technologies and contributors
// Copyright (c) 2019, Frappe Technologies and contributors
// For license information, please see license.txt
/* eslint-disable */
frappe.query_reports["Transaction Log Report"] = {
onload: function(query_report) {
query_report.add_make_chart_button = function() {
//
};
}
}

View file

@ -6,7 +6,7 @@
"doctype": "Report",
"idx": 0,
"is_standard": "Yes",
"modified": "2018-06-29 15:46:46.884862",
"modified": "2018-12-27 18:10:29.785415",
"modified_by": "Administrator",
"module": "Core",
"name": "Transaction Log Report",
@ -18,6 +18,9 @@
"roles": [
{
"role": "Administrator"
},
{
"role": "System Manager"
}
]
}

View file

@ -1,10 +1,11 @@
# Copyright (c) 2013, Frappe Technologies and contributors
# Copyright (c) 2019, Frappe Technologies and contributors
# For license information, please see license.txt
from __future__ import unicode_literals
import frappe
import hashlib
from frappe import _
from frappe.utils import format_datetime
def execute(filters=None):
columns, data = get_columns(filters), get_data(filters)
@ -24,9 +25,9 @@ def get_data(filters=None):
else:
integrity = check_data_integrity(l.chaining_hash, l.transaction_hash, l.previous_hash, previous_hash[0][0])
result.append([str(integrity), l.reference_doctype, l.document_name, l.owner, l.modified_by, l.timestamp])
result.append([_(str(integrity)), _(l.reference_doctype), l.document_name, l.owner, l.modified_by, format_datetime(l.timestamp, "YYYYMMDDHHmmss")])
else:
result.append([_("First Transaction"), l.reference_doctype, l.document_name, l.owner, l.modified_by, l.timestamp])
result.append([_("First Transaction"), _(l.reference_doctype), l.document_name, l.owner, l.modified_by, format_datetime(l.timestamp, "YYYYMMDDHHmmss")])
return result