mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2025-12-20 18:11:08 -05:00
fix commas
This commit is contained in:
23
history_tracking/mixins.py
Normal file
23
history_tracking/mixins.py
Normal 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
|
||||
Reference in New Issue
Block a user