fix(core): Correct attribute names for referencing a Centurion Model from an AuditModel

ref: #772 #759
This commit is contained in:
2025-05-25 09:00:27 +09:30
parent d3347082d1
commit 9425793190
2 changed files with 4 additions and 4 deletions

View File

@ -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',

View File

@ -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')