feat(core): Add model instance to history object during history creation
ref: #772 #759
This commit is contained in:
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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,
|
||||
)
|
||||
|
Reference in New Issue
Block a user