8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-28 23:52:26 +00:00

Merge branch 'fix_user_history_key_error' into 'dev'

Fix #295

See merge request re2o/re2o!567
This commit is contained in:
klafyvel 2020-11-12 11:33:59 +01:00
commit 850dcfb800

View file

@ -373,15 +373,26 @@ class HistoryEvent:
edits = [] edits = []
for field in self.edited_fields: for field in self.edited_fields:
old_value = None
new_value = None
if field in hide: if field in hide:
# Don't show sensitive information # Don't show sensitive information, so leave values at None
edits.append((field, None, None)) pass
else: else:
edits.append(( # Take into account keys that may exist in only one dict
field, if field in self.previous_version.field_dict:
self._repr(field, self.previous_version.field_dict[field]), old_value = self._repr(
self._repr(field, self.version.field_dict[field]) field,
)) self.previous_version.field_dict[field]
)
if field in self.version.field_dict:
new_value = self._repr(
field,
self.version.field_dict[field]
)
edits.append((field, old_value, new_value))
return edits return edits
@ -438,9 +449,15 @@ class History:
v2. v2.
""" """
fields = [] fields = []
v1_keys = set([k for k in v1.field_dict.keys() if k not in ignoring])
v2_keys = set([k for k in v2.field_dict.keys() if k not in ignoring])
for key in v1.field_dict.keys(): common_keys = v1_keys.intersection(v2_keys)
if key not in ignoring and v1.field_dict[key] != v2.field_dict[key]: fields += list(v2_keys - v1_keys)
fields += list(v1_keys - v2_keys)
for key in common_keys:
if v1.field_dict[key] != v2.field_dict[key]:
fields.append(key) fields.append(key)
return fields return fields
@ -541,9 +558,15 @@ class VersionAction(HistoryEvent):
v2. v2.
""" """
fields = [] fields = []
v1_keys = set([k for k in v1.field_dict.keys() if k not in ignoring])
v2_keys = set([k for k in v2.field_dict.keys() if k not in ignoring])
for key in v1.field_dict.keys(): common_keys = v1_keys.intersection(v2_keys)
if key not in ignoring and v1.field_dict[key] != v2.field_dict[key]: fields += list(v2_keys - v1_keys)
fields += list(v1_keys - v2_keys)
for key in common_keys:
if v1.field_dict[key] != v2.field_dict[key]:
fields.append(key) fields.append(key)
return fields return fields