From d4d0604da218a1fd4f9ef973b527957ea05e819f Mon Sep 17 00:00:00 2001 From: Trenton H <797416+stumpylog@users.noreply.github.com> Date: Wed, 8 May 2024 09:04:32 -0700 Subject: [PATCH] Moves additional auditlog imports into protected blocks (#6638) --- src/documents/management/commands/document_exporter.py | 6 +++--- src/documents/serialisers.py | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/documents/management/commands/document_exporter.py b/src/documents/management/commands/document_exporter.py index b02fd686b..081dfb360 100644 --- a/src/documents/management/commands/document_exporter.py +++ b/src/documents/management/commands/document_exporter.py @@ -9,9 +9,6 @@ from typing import Optional import tqdm from django.conf import settings - -if settings.AUDIT_LOG_ENABLED: - from auditlog.models import LogEntry from django.contrib.auth.models import Group from django.contrib.auth.models import Permission from django.contrib.auth.models import User @@ -25,6 +22,9 @@ from filelock import FileLock from guardian.models import GroupObjectPermission from guardian.models import UserObjectPermission +if settings.AUDIT_LOG_ENABLED: + from auditlog.models import LogEntry + from documents.file_handling import delete_empty_directories from documents.file_handling import generate_filename from documents.models import Correspondent diff --git a/src/documents/serialisers.py b/src/documents/serialisers.py index 213e3cc27..ebe857948 100644 --- a/src/documents/serialisers.py +++ b/src/documents/serialisers.py @@ -5,7 +5,6 @@ import zoneinfo from decimal import Decimal import magic -from auditlog.context import set_actor from celery import states from django.conf import settings from django.contrib.auth.models import Group @@ -28,6 +27,9 @@ from rest_framework import fields from rest_framework import serializers from rest_framework.fields import SerializerMethodField +if settings.AUDIT_LOG_ENABLED: + from auditlog.context import set_actor + from documents import bulk_edit from documents.data_models import DocumentSource from documents.models import Correspondent