A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
Get rid of fill_list and rather use defaultdict
Wolf-Bastian Poettner7f1e1052fe5b
diff --git a/src/documents/models.py b/src/documents/models.pyindex 4929ea459..39dcc4a37 100644--- a/src/documents/models.py+++ b/src/documents/models.py@@ -328,25 +328,15 @@ class Document(models.Model):if settings.PAPERLESS_FILENAME_FORMAT is not None:tag = defaultdict(lambda: slugify(None),self.many_to_dictionary(self.tags))- list_length = 10- tags = self.many_to_list(self.tags)- while True:- tags = Document.fill_list(tags, list_length, None)- try:- path = settings.PAPERLESS_FILENAME_FORMAT.format(- correspondent=slugify(self.correspondent),- title=slugify(self.title),- created=slugify(self.created),- added=slugify(self.added),- tag=tag,- tags=tags)- break- except IndexError:- list_length *= 10-- if list_length > 1000:- path = ""- break+ tags = defaultdict(lambda: slugify(None),+ enumerate(self.many_to_list(self.tags)))+ path = settings.PAPERLESS_FILENAME_FORMAT.format(+ correspondent=slugify(self.correspondent),+ title=slugify(self.title),+ created=slugify(self.created),+ added=slugify(self.added),+ tag=tag,+ tags=tags)else:path = ""diff --git a/src/documents/tests/test_file_handling.py b/src/documents/tests/test_file_handling.pyindex 3065948ea..f6c8d0eba 100644--- a/src/documents/tests/test_file_handling.py+++ b/src/documents/tests/test_file_handling.py@@ -264,7 +264,7 @@ class TestDate(TestCase):# Ensure that filename is properly generatedtmp = document.source_filenameself.assertEqual(document.generate_source_filename(),- "0000001.pdf")+ "none-0000001.pdf")document.create_source_directory()Path(document.source_path).touch()