fix commas

This commit is contained in:
pacnpal
2024-11-03 20:21:39 +00:00
parent d3a69072d2
commit d4b08bbaed
21 changed files with 390 additions and 98 deletions

View File

@@ -0,0 +1,23 @@
# history_tracking/mixins.py
class HistoricalChangeMixin:
@property
def diff_against_previous(self):
prev_record = self.prev_record
if not prev_record:
return {}
changes = {}
for field in self.__dict__:
if field not in [
"history_date",
"history_id",
"history_type",
"history_user_id",
] and not field.startswith("_"):
old_value = getattr(prev_record, field)
new_value = getattr(self, field)
if old_value != new_value:
changes[field] = {"old": old_value, "new": new_value}
return changes