fix(core): Correct attribute names for referencing a Centurion Model from an AuditModel
ref: #772 #759
This commit is contained in:
@ -145,21 +145,21 @@ class CenturionAudit(
|
||||
Fail (bool): History fields not populated
|
||||
"""
|
||||
|
||||
if not hasattr(model, 'before'):
|
||||
if not hasattr(model, '_before'):
|
||||
|
||||
raise ValidationError(
|
||||
code = 'model_missing_before_data',
|
||||
message = 'Unable to save model history as the "before" data is missing.'
|
||||
)
|
||||
|
||||
if not hasattr(model, 'after'):
|
||||
if not hasattr(model, '_after'):
|
||||
|
||||
raise ValidationError(
|
||||
code = 'model_missing_after_data',
|
||||
message = 'Unable to save model history as the "after" data is missing.'
|
||||
)
|
||||
|
||||
if model.before == model.after:
|
||||
if model._before == model._after:
|
||||
|
||||
raise ValidationError(
|
||||
code = 'before_and_after_same',
|
||||
|
@ -13,7 +13,7 @@ from core.middleware.get_request import get_request
|
||||
@receiver(post_save, dispatch_uid="audit_history_save")
|
||||
def audit_history(sender, instance, **kwargs):
|
||||
|
||||
if getattr(instance, 'audit_enabled', False):
|
||||
if getattr(instance, '_audit_enabled', False):
|
||||
|
||||
audit_model = apps.get_model( instance._meta.object_name + 'AuditHistory')
|
||||
|
||||
|
Reference in New Issue
Block a user