[gen] Bugfixes in historization.

This commit is contained in:
Gaetan Delannay 2013-01-10 11:47:39 +01:00
parent c863b47db5
commit f4e40caf5c
2 changed files with 11 additions and 2 deletions

View file

@ -1041,7 +1041,8 @@ class BaseMixin:
else: else:
for event in history: for event in history:
if (event['action'] == '_datachange_') and \ 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, def getHistory(self, startNumber=0, reverse=True, includeInvisible=False,
batchSize=5): batchSize=5):
@ -1079,7 +1080,7 @@ class BaseMixin:
(field.format == gen.String.XHTML): (field.format == gen.String.XHTML):
# For rich text fields, instead of simply showing the # For rich text fields, instead of simply showing the
# previous value, we propose a diff with the next # previous value, we propose a diff with the next
# version. # version, excepted if the previous value is empty.
if field.isEmptyValue(oldValue[0]): if field.isEmptyValue(oldValue[0]):
val = '-' val = '-'
else: else:

View file

@ -660,6 +660,14 @@ class HtmlDiff:
def get(self): def get(self):
'''Produces the result.''' '''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 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') return self.getHtmlDiff(self.old, self.new, '\n')
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------