mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-30 03:56:23 -05:00 
			
		
		
		
	Merge pull request #326 from CkuT/new_document_list
New imported documents list
This commit is contained in:
		| @@ -15,13 +15,15 @@ class DocumentsConfig(AppConfig): | |||||||
|             set_tags, |             set_tags, | ||||||
|             run_pre_consume_script, |             run_pre_consume_script, | ||||||
|             run_post_consume_script, |             run_post_consume_script, | ||||||
|             cleanup_document_deletion |             cleanup_document_deletion, | ||||||
|  |             set_log_entry | ||||||
|         ) |         ) | ||||||
|  |  | ||||||
|         document_consumption_started.connect(run_pre_consume_script) |         document_consumption_started.connect(run_pre_consume_script) | ||||||
|  |  | ||||||
|         document_consumption_finished.connect(set_tags) |         document_consumption_finished.connect(set_tags) | ||||||
|         document_consumption_finished.connect(set_correspondent) |         document_consumption_finished.connect(set_correspondent) | ||||||
|  |         document_consumption_finished.connect(set_log_entry) | ||||||
|         document_consumption_finished.connect(run_post_consume_script) |         document_consumption_finished.connect(run_post_consume_script) | ||||||
|  |  | ||||||
|         post_delete.connect(cleanup_document_deletion) |         post_delete.connect(cleanup_document_deletion) | ||||||
|   | |||||||
| @@ -3,6 +3,11 @@ import os | |||||||
| from subprocess import Popen | from subprocess import Popen | ||||||
|  |  | ||||||
| from django.conf import settings | from django.conf import settings | ||||||
|  | from django.contrib.admin.models import ADDITION, LogEntry | ||||||
|  | from django.contrib.auth.models import User | ||||||
|  | from django.contrib.contenttypes.models import ContentType | ||||||
|  |  | ||||||
|  | from datetime import datetime | ||||||
|  |  | ||||||
| from ..models import Correspondent, Document, Tag | from ..models import Correspondent, Document, Tag | ||||||
|  |  | ||||||
| @@ -93,3 +98,18 @@ def cleanup_document_deletion(sender, instance, using, **kwargs): | |||||||
|             os.unlink(f) |             os.unlink(f) | ||||||
|         except FileNotFoundError: |         except FileNotFoundError: | ||||||
|             pass  # The file's already gone, so we're cool with it. |             pass  # The file's already gone, so we're cool with it. | ||||||
|  |  | ||||||
|  |  | ||||||
|  | def set_log_entry(sender, document=None, logging_group=None, **kwargs): | ||||||
|  |  | ||||||
|  |     ct = ContentType.objects.get(model="document") | ||||||
|  |     user = User.objects.first() | ||||||
|  |  | ||||||
|  |     LogEntry.objects.create( | ||||||
|  |         action_flag=ADDITION, | ||||||
|  |         action_time=datetime.now(), | ||||||
|  |         content_type=ct, | ||||||
|  |         object_id=document.id, | ||||||
|  |         user=user, | ||||||
|  |         object_repr=document.__str__(), | ||||||
|  |     ) | ||||||
|   | |||||||
| @@ -1,5 +1,7 @@ | |||||||
| from random import randint | from random import randint | ||||||
|  |  | ||||||
|  | from django.contrib.admin.models import LogEntry | ||||||
|  | from django.contrib.auth.models import User | ||||||
| from django.test import TestCase, override_settings | from django.test import TestCase, override_settings | ||||||
|  |  | ||||||
| from ..models import Correspondent, Document, Tag | from ..models import Correspondent, Document, Tag | ||||||
| @@ -208,6 +210,7 @@ class TestDocumentConsumptionFinishedSignal(TestCase): | |||||||
|  |  | ||||||
|     def setUp(self): |     def setUp(self): | ||||||
|         TestCase.setUp(self) |         TestCase.setUp(self) | ||||||
|  |         User.objects.create_user(username='testuser', password='12345') | ||||||
|         self.doc_contains = Document.objects.create( |         self.doc_contains = Document.objects.create( | ||||||
|             content="I contain the keyword.", file_type="pdf") |             content="I contain the keyword.", file_type="pdf") | ||||||
|  |  | ||||||
| @@ -244,3 +247,9 @@ class TestDocumentConsumptionFinishedSignal(TestCase): | |||||||
|         document_consumption_finished.send( |         document_consumption_finished.send( | ||||||
|             sender=self.__class__, document=self.doc_contains) |             sender=self.__class__, document=self.doc_contains) | ||||||
|         self.assertEqual(self.doc_contains.correspondent, None) |         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) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Daniel Quinn
					Daniel Quinn