Exclude member_forms history change, fix truncation bug
This commit is contained in:
parent
4ecb84bc96
commit
37d0030966
|
@ -47,7 +47,7 @@ class Member(models.Model):
|
||||||
paused_date = models.DateField(blank=True, null=True)
|
paused_date = models.DateField(blank=True, null=True)
|
||||||
monthly_fees = models.IntegerField(default=55, 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):
|
class Transaction(models.Model):
|
||||||
user = models.ForeignKey(User, related_name='transactions', blank=True, null=True, on_delete=models.SET_NULL)
|
user = models.ForeignKey(User, related_name='transactions', blank=True, null=True, on_delete=models.SET_NULL)
|
||||||
|
|
|
@ -49,7 +49,7 @@ def post_create_historical_record_callback(
|
||||||
changes = []
|
changes = []
|
||||||
|
|
||||||
# it's possible for changes to be empty if model saved with no diff
|
# 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)
|
owner = get_object_owner(instance)
|
||||||
|
|
||||||
index = models.HistoryIndex.objects.create(
|
index = models.HistoryIndex.objects.create(
|
||||||
|
@ -65,15 +65,15 @@ def post_create_historical_record_callback(
|
||||||
is_admin=is_admin_director(history_user),
|
is_admin=is_admin_director(history_user),
|
||||||
)
|
)
|
||||||
|
|
||||||
change_old = change.old or ''
|
for change in changes:
|
||||||
change_new = change.new or ''
|
change_old = str(change.old)
|
||||||
|
change_new = str(change.new)
|
||||||
|
|
||||||
if len(change_old) > 200:
|
if len(change_old) > 200:
|
||||||
change_old = change_old[:200] + '... [truncated]'
|
change_old = change_old[:200] + '... [truncated]'
|
||||||
if len(change_new) > 200:
|
if len(change_new) > 200:
|
||||||
change_new = change_new[:200] + '... [truncated]'
|
change_new = change_new[:200] + '... [truncated]'
|
||||||
|
|
||||||
for change in changes:
|
|
||||||
models.HistoryChange.objects.create(
|
models.HistoryChange.objects.create(
|
||||||
index=index,
|
index=index,
|
||||||
field=change.field,
|
field=change.field,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user