From 51b0f6e3253b071525b913237ada7b5462182ea2 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Wed, 1 Jan 2025 10:11:54 -0800 Subject: [PATCH] Fix: remove outdated admin logentry handler (#8580) --- src/documents/apps.py | 2 -- src/documents/signals/handlers.py | 18 ------------------ src/documents/tests/test_matchables.py | 9 --------- 3 files changed, 29 deletions(-) diff --git a/src/documents/apps.py b/src/documents/apps.py index c00b23ff2..ac1bb21eb 100644 --- a/src/documents/apps.py +++ b/src/documents/apps.py @@ -16,7 +16,6 @@ class DocumentsConfig(AppConfig): from documents.signals.handlers import run_workflows_updated from documents.signals.handlers import set_correspondent from documents.signals.handlers import set_document_type - from documents.signals.handlers import set_log_entry from documents.signals.handlers import set_storage_path from documents.signals.handlers import set_tags @@ -25,7 +24,6 @@ class DocumentsConfig(AppConfig): document_consumption_finished.connect(set_document_type) document_consumption_finished.connect(set_tags) document_consumption_finished.connect(set_storage_path) - document_consumption_finished.connect(set_log_entry) document_consumption_finished.connect(add_to_index) document_consumption_finished.connect(run_workflows_added) document_updated.connect(run_workflows_updated) diff --git a/src/documents/signals/handlers.py b/src/documents/signals/handlers.py index d669e3a0f..d3fa11b3b 100644 --- a/src/documents/signals/handlers.py +++ b/src/documents/signals/handlers.py @@ -10,10 +10,6 @@ from celery.signals import task_failure from celery.signals import task_postrun from celery.signals import task_prerun from django.conf import settings -from django.contrib.admin.models import ADDITION -from django.contrib.admin.models import LogEntry -from django.contrib.auth.models import User -from django.contrib.contenttypes.models import ContentType from django.core.mail import EmailMessage from django.db import DatabaseError from django.db import close_old_connections @@ -537,20 +533,6 @@ def check_paths_and_prune_custom_fields(sender, instance: CustomField, **kwargs) update_filename_and_move_files(sender, cf_instance) -def set_log_entry(sender, document: Document, logging_group=None, **kwargs): - ct = ContentType.objects.get(model="document") - user = User.objects.get(username="consumer") - - LogEntry.objects.create( - action_flag=ADDITION, - action_time=timezone.now(), - content_type=ct, - object_id=document.pk, - user=user, - object_repr=document.__str__(), - ) - - def add_to_index(sender, document, **kwargs): from documents import index diff --git a/src/documents/tests/test_matchables.py b/src/documents/tests/test_matchables.py index 4626e2c08..9ca23e53d 100644 --- a/src/documents/tests/test_matchables.py +++ b/src/documents/tests/test_matchables.py @@ -4,7 +4,6 @@ from collections.abc import Iterable from pathlib import Path from random import randint -from django.contrib.admin.models import LogEntry from django.contrib.auth.models import User from django.test import TestCase from django.test import override_settings @@ -451,11 +450,3 @@ class TestDocumentConsumptionFinishedSignal(TestCase): document=self.doc_contains, ) self.assertEqual(self.doc_contains.correspondent, None) - - def test_logentry_created(self): - document_consumption_finished.send( - sender=self.__class__, - document=self.doc_contains, - ) - - self.assertEqual(LogEntry.objects.count(), 1)