mirror of
https://github.com/jazzband/django-auditlog.git
synced 2026-05-12 09:33:11 +00:00
Be able to disable audit logging from django settings
Keep existing behaviour for allowing disabling auditlog app wide.
In Mathspace monolity, this is configured as:
AUDITLOG = {"disable_auditlog": False}
This commit is contained in:
parent
cd0518a164
commit
b03f54f594
2 changed files with 9 additions and 0 deletions
|
|
@ -40,3 +40,6 @@ settings.AUDITLOG_TWO_STEP_MIGRATION = getattr(
|
|||
settings.AUDITLOG_USE_TEXT_CHANGES_IF_JSON_IS_NOT_PRESENT = getattr(
|
||||
settings, "AUDITLOG_USE_TEXT_CHANGES_IF_JSON_IS_NOT_PRESENT", False
|
||||
)
|
||||
|
||||
# Custom
|
||||
settings.AUDITLOG_DISABLE_AUDITLOG = getattr(settings, "AUDITLOG", {}).get("disable_auditlog", False)
|
||||
|
|
|
|||
|
|
@ -55,6 +55,9 @@ class AuditlogModelRegistry:
|
|||
self._signals = {}
|
||||
self._m2m_signals = defaultdict(dict)
|
||||
|
||||
if settings.AUDITLOG_DISABLE_AUDITLOG:
|
||||
return
|
||||
|
||||
if create:
|
||||
self._signals[post_save] = log_create
|
||||
if update:
|
||||
|
|
@ -195,6 +198,9 @@ class AuditlogModelRegistry:
|
|||
"""
|
||||
from auditlog.receivers import make_log_m2m_changes
|
||||
|
||||
if settings.AUDITLOG_DISABLE_AUDITLOG:
|
||||
return
|
||||
|
||||
for signal, receiver in self._signals.items():
|
||||
signal.connect(
|
||||
receiver,
|
||||
|
|
|
|||
Loading…
Reference in a new issue