Skip to content

Commit 89c63fb

Browse files
author
Brylie Christopher Oxley
committed
Fix diff perspective for clearer semantics
1 parent cad8348 commit 89c63fb

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

simple_history/models.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -427,12 +427,12 @@ def get_next_record_diff(self):
427427
"""
428428
Get the difference between this and the next record. `None` of no next record.
429429
"""
430-
430+
431431
next_record = self.get_next_record()
432-
432+
433433
if next_record is not None:
434434
return self.diff_against(previous_record)
435-
435+
436436
return None
437437

438438
def get_prev_record(self):
@@ -449,13 +449,15 @@ def get_prev_record(self):
449449
def get_prev_record_diff(self):
450450
"""
451451
Get the difference between this and the previous record. `None` if no previous record.
452+
453+
The diff should be based on the previous record, since the diff uses `old_record` and `new_record` semantics.
452454
"""
453-
455+
454456
previous_record = self.get_prev_record()
455-
457+
456458
if previous_record is not None:
457-
return self.diff_against(previous_record)
458-
459+
return previous_record.diff_against(self)
460+
459461
return None
460462

461463
def get_default_history_user(instance):

0 commit comments

Comments
 (0)