Exclude member_forms history change, fix truncation bug

This commit is contained in:
Tanner Collin 2020-02-26 00:54:07 +00:00
parent 4ecb84bc96
commit 37d0030966
2 changed files with 10 additions and 10 deletions

View File

@ -47,7 +47,7 @@ class Member(models.Model):
paused_date = models.DateField(blank=True, null=True)
monthly_fees = models.IntegerField(default=55, blank=True, null=True)
history = HistoricalRecords()
history = HistoricalRecords(excluded_fields=['member_forms'])
class Transaction(models.Model):
user = models.ForeignKey(User, related_name='transactions', blank=True, null=True, on_delete=models.SET_NULL)

View File

@ -49,7 +49,7 @@ def post_create_historical_record_callback(
changes = []
# it's possible for changes to be empty if model saved with no diff
if changes or history_type in ['Created', 'Deleted']:
if len(changes) or history_type in ['Created', 'Deleted']:
owner = get_object_owner(instance)
index = models.HistoryIndex.objects.create(
@ -65,15 +65,15 @@ def post_create_historical_record_callback(
is_admin=is_admin_director(history_user),
)
change_old = change.old or ''
change_new = change.new or ''
for change in changes:
change_old = str(change.old)
change_new = str(change.new)
if len(change_old) > 200:
change_old = change_old[:200] + '... [truncated]'
if len(change_new) > 200:
change_new = change_new[:200] + '... [truncated]'
for change in changes:
models.HistoryChange.objects.create(
index=index,
field=change.field,