feat(core): Add model instance to history object during history creation

ref: #772 #759
This commit is contained in:
2025-05-25 09:02:15 +09:30
parent 7a1e9e10a3
commit bc1f12c47f
3 changed files with 5 additions and 15 deletions

View File

@ -7,8 +7,4 @@ from access.models.tenancy_abstract import TenancyAbstractModel
@pytest.fixture( scope = 'class')
def model(request):
request.cls.model = TenancyAbstractModel
yield request.cls.model
del request.cls.model
yield TenancyAbstractModel

View File

@ -1,12 +1,7 @@
# import inspect
import inspect
import pytest
# import rest_framework
from django.db import models
# from django.core.exceptions import (
# ValidationError
# )
# from django.utils.timezone import now
from centurion.tests.unit_models import ModelTestCases

View File

@ -15,7 +15,7 @@ def audit_history(sender, instance, **kwargs):
if getattr(instance, '_audit_enabled', False):
audit_model = apps.get_model( instance._meta.object_name + 'AuditHistory')
audit_model = apps.get_model( instance._meta.app_label, instance._meta.object_name + 'AuditHistory')
audit_action = audit_model.Actions.UPDATE
@ -34,8 +34,7 @@ def audit_history(sender, instance, **kwargs):
app_label = instance._meta.app_label,
model = instance._meta.model_name,
),
before = instance.get_before(),
after = instance.get_after(),
action = audit_action,
user = get_request().user
user = get_request().user,
model = instance,
)