[gen] Bugfixes in historization.
This commit is contained in:
parent
c863b47db5
commit
f4e40caf5c
|
@ -1041,7 +1041,8 @@ class BaseMixin:
|
|||
else:
|
||||
for event in history:
|
||||
if (event['action'] == '_datachange_') and \
|
||||
(fieldName in event['changes']): return True
|
||||
(fieldName in event['changes']) and \
|
||||
event['changes'][fieldName][0]: return True
|
||||
|
||||
def getHistory(self, startNumber=0, reverse=True, includeInvisible=False,
|
||||
batchSize=5):
|
||||
|
@ -1079,7 +1080,7 @@ class BaseMixin:
|
|||
(field.format == gen.String.XHTML):
|
||||
# For rich text fields, instead of simply showing the
|
||||
# previous value, we propose a diff with the next
|
||||
# version.
|
||||
# version, excepted if the previous value is empty.
|
||||
if field.isEmptyValue(oldValue[0]):
|
||||
val = '-'
|
||||
else:
|
||||
|
|
|
@ -660,6 +660,14 @@ class HtmlDiff:
|
|||
|
||||
def get(self):
|
||||
'''Produces the result.'''
|
||||
# Normally, if self.old is empty, the whole self.new should be
|
||||
# considered as inserted text. But see this line:
|
||||
if not self.old or not self.old.strip(): return self.new
|
||||
# Why? This is for avoiding problems in the case of cumulative diffs.
|
||||
# A cumulative diff means: calling HtmlDiff with, as old value, the
|
||||
# result of a previous call to HtmlDiff. In this case, if the whole text
|
||||
# is already considered as inserted, we will already have overlaps in
|
||||
# the next diff. Overlaps are hard to manage, so we avoid to get them
|
||||
# as a starting point when computing cumulative diffs.
|
||||
return self.getHtmlDiff(self.old, self.new, '\n')
|
||||
# ------------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in a new issue