Unregister auditlog during import
This commit is contained in:
parent
57709591f3
commit
a6104b8cf6
@ -21,7 +21,13 @@ from django.db.models.signals import post_save
|
|||||||
from filelock import FileLock
|
from filelock import FileLock
|
||||||
|
|
||||||
from documents.file_handling import create_source_path_directory
|
from documents.file_handling import create_source_path_directory
|
||||||
|
from documents.models import Correspondent
|
||||||
|
from documents.models import CustomField
|
||||||
|
from documents.models import CustomFieldInstance
|
||||||
from documents.models import Document
|
from documents.models import Document
|
||||||
|
from documents.models import DocumentType
|
||||||
|
from documents.models import Note
|
||||||
|
from documents.models import Tag
|
||||||
from documents.parsers import run_convert
|
from documents.parsers import run_convert
|
||||||
from documents.settings import EXPORTER_ARCHIVE_NAME
|
from documents.settings import EXPORTER_ARCHIVE_NAME
|
||||||
from documents.settings import EXPORTER_FILE_NAME
|
from documents.settings import EXPORTER_FILE_NAME
|
||||||
@ -30,6 +36,9 @@ from documents.signals.handlers import update_filename_and_move_files
|
|||||||
from documents.utils import copy_file_with_basic_stats
|
from documents.utils import copy_file_with_basic_stats
|
||||||
from paperless import version
|
from paperless import version
|
||||||
|
|
||||||
|
if not settings.AUDIT_LOG_DISABLED:
|
||||||
|
from auditlog.registry import auditlog
|
||||||
|
|
||||||
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
def disable_signal(sig, receiver, sender):
|
def disable_signal(sig, receiver, sender):
|
||||||
@ -151,6 +160,15 @@ class Command(BaseCommand):
|
|||||||
receiver=update_filename_and_move_files,
|
receiver=update_filename_and_move_files,
|
||||||
sender=Document.tags.through,
|
sender=Document.tags.through,
|
||||||
):
|
):
|
||||||
|
if not settings.AUDIT_LOG_DISABLED:
|
||||||
|
auditlog.unregister(Document)
|
||||||
|
auditlog.unregister(Correspondent)
|
||||||
|
auditlog.unregister(Tag)
|
||||||
|
auditlog.unregister(DocumentType)
|
||||||
|
auditlog.unregister(Note)
|
||||||
|
auditlog.unregister(CustomField)
|
||||||
|
auditlog.unregister(CustomFieldInstance)
|
||||||
|
|
||||||
# Fill up the database with whatever is in the manifest
|
# Fill up the database with whatever is in the manifest
|
||||||
try:
|
try:
|
||||||
with transaction.atomic():
|
with transaction.atomic():
|
||||||
|
@ -7,7 +7,6 @@ from pathlib import Path
|
|||||||
from unittest import mock
|
from unittest import mock
|
||||||
from zipfile import ZipFile
|
from zipfile import ZipFile
|
||||||
|
|
||||||
from auditlog.models import LogEntry
|
|
||||||
from django.contrib.auth.models import Group
|
from django.contrib.auth.models import Group
|
||||||
from django.contrib.auth.models import Permission
|
from django.contrib.auth.models import Permission
|
||||||
from django.contrib.contenttypes.models import ContentType
|
from django.contrib.contenttypes.models import ContentType
|
||||||
@ -123,19 +122,6 @@ class TestExportImport(DirectoriesMixin, FileSystemAssertsMixin, TestCase):
|
|||||||
self.workflow.actions.add(self.action)
|
self.workflow.actions.add(self.action)
|
||||||
self.workflow.save()
|
self.workflow.save()
|
||||||
|
|
||||||
LogEntry.objects.log_create(
|
|
||||||
instance=self.dt1,
|
|
||||||
changes=json.dumps(
|
|
||||||
{
|
|
||||||
"name": [
|
|
||||||
self.dt1.name,
|
|
||||||
"New name",
|
|
||||||
],
|
|
||||||
},
|
|
||||||
),
|
|
||||||
action=LogEntry.Action.UPDATE,
|
|
||||||
)
|
|
||||||
|
|
||||||
super().setUp()
|
super().setUp()
|
||||||
|
|
||||||
def _get_document_from_manifest(self, manifest, id):
|
def _get_document_from_manifest(self, manifest, id):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user