diff --git a/Pipfile.lock b/Pipfile.lock index 35d33c2a7..2aa409ba1 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "3b7d7fbb271204d23f9cf66d0bdc9e77f5f995fccc2351816043d63b4dbec019" + "sha256": "f11be7db7651d097cd7b48b33570e88992c4c4d9819a66e56d6b1e578534c984" }, "pipfile-spec": 6, "requires": {}, @@ -471,11 +471,11 @@ }, "django-allauth": { "hashes": [ - "sha256:e449d2378e1f33803bcf6f1ecc28439ce383de9b5c128a66aa301c4a0e71806f" + "sha256:5b4ae515ea74f54f0041210692eee10c309ad15ddbbd03d3620693c75e3f7945" ], "index": "pypi", "markers": "python_version >= '3.7'", - "version": "==0.61.0" + "version": "==0.61.1" }, "django-auditlog": { "hashes": [ @@ -2496,32 +2496,32 @@ }, "black": { "hashes": [ - "sha256:0269dfdea12442022e88043d2910429bed717b2d04523867a85dacce535916b8", - "sha256:07204d078e25327aad9ed2c64790d681238686bce254c910de640c7cc4fc3aa6", - "sha256:08b34e85170d368c37ca7bf81cf67ac863c9d1963b2c1780c39102187ec8dd62", - "sha256:1a95915c98d6e32ca43809d46d932e2abc5f1f7d582ffbe65a5b4d1588af7445", - "sha256:2588021038bd5ada078de606f2a804cadd0a3cc6a79cb3e9bb3a8bf581325a4c", - "sha256:2fa6a0e965779c8f2afb286f9ef798df770ba2b6cee063c650b96adec22c056a", - "sha256:34afe9da5056aa123b8bfda1664bfe6fb4e9c6f311d8e4a6eb089da9a9173bf9", - "sha256:3897ae5a21ca132efa219c029cce5e6bfc9c3d34ed7e892113d199c0b1b444a2", - "sha256:40657e1b78212d582a0edecafef133cf1dd02e6677f539b669db4746150d38f6", - "sha256:48b5760dcbfe5cf97fd4fba23946681f3a81514c6ab8a45b50da67ac8fbc6c7b", - "sha256:5242ecd9e990aeb995b6d03dc3b2d112d4a78f2083e5a8e86d566340ae80fec4", - "sha256:5cdc2e2195212208fbcae579b931407c1fa9997584f0a415421748aeafff1168", - "sha256:5d7b06ea8816cbd4becfe5f70accae953c53c0e53aa98730ceccb0395520ee5d", - "sha256:7258c27115c1e3b5de9ac6c4f9957e3ee2c02c0b39222a24dc7aa03ba0e986f5", - "sha256:854c06fb86fd854140f37fb24dbf10621f5dab9e3b0c29a690ba595e3d543024", - "sha256:a21725862d0e855ae05da1dd25e3825ed712eaaccef6b03017fe0853a01aa45e", - "sha256:a83fe522d9698d8f9a101b860b1ee154c1d25f8a82ceb807d319f085b2627c5b", - "sha256:b3d64db762eae4a5ce04b6e3dd745dcca0fb9560eb931a5be97472e38652a161", - "sha256:e298d588744efda02379521a19639ebcd314fba7a49be22136204d7ed1782717", - "sha256:e2c8dfa14677f90d976f68e0c923947ae68fa3961d61ee30976c388adc0b02c8", - "sha256:ecba2a15dfb2d97105be74bbfe5128bc5e9fa8477d8c46766505c1dda5883aac", - "sha256:fc1ec9aa6f4d98d022101e015261c056ddebe3da6a8ccfc2c792cbe0349d48b7" + "sha256:057c3dc602eaa6fdc451069bd027a1b2635028b575a6c3acfd63193ced20d9c8", + "sha256:08654d0797e65f2423f850fc8e16a0ce50925f9337fb4a4a176a7aa4026e63f8", + "sha256:163baf4ef40e6897a2a9b83890e59141cc8c2a98f2dda5080dc15c00ee1e62cd", + "sha256:1e08fb9a15c914b81dd734ddd7fb10513016e5ce7e6704bdd5e1251ceee51ac9", + "sha256:4dd76e9468d5536abd40ffbc7a247f83b2324f0c050556d9c371c2b9a9a95e31", + "sha256:4f9de21bafcba9683853f6c96c2d515e364aee631b178eaa5145fc1c61a3cc92", + "sha256:61a0391772490ddfb8a693c067df1ef5227257e72b0e4108482b8d41b5aee13f", + "sha256:6981eae48b3b33399c8757036c7f5d48a535b962a7c2310d19361edeef64ce29", + "sha256:7e53a8c630f71db01b28cd9602a1ada68c937cbf2c333e6ed041390d6968faf4", + "sha256:810d445ae6069ce64030c78ff6127cd9cd178a9ac3361435708b907d8a04c693", + "sha256:93601c2deb321b4bad8f95df408e3fb3943d85012dddb6121336b8e24a0d1218", + "sha256:992e451b04667116680cb88f63449267c13e1ad134f30087dec8527242e9862a", + "sha256:9db528bccb9e8e20c08e716b3b09c6bdd64da0dd129b11e160bf082d4642ac23", + "sha256:a0057f800de6acc4407fe75bb147b0c2b5cbb7c3ed110d3e5999cd01184d53b0", + "sha256:ba15742a13de85e9b8f3239c8f807723991fbfae24bad92d34a2b12e81904982", + "sha256:bce4f25c27c3435e4dace4815bcb2008b87e167e3bf4ee47ccdc5ce906eb4894", + "sha256:ca610d29415ee1a30a3f30fab7a8f4144e9d34c89a235d81292a1edb2b55f540", + "sha256:d533d5e3259720fdbc1b37444491b024003e012c5173f7d06825a77508085430", + "sha256:d84f29eb3ee44859052073b7636533ec995bd0f64e2fb43aeceefc70090e752b", + "sha256:e37c99f89929af50ffaf912454b3e3b47fd64109659026b678c091a4cd450fb2", + "sha256:e8a6ae970537e67830776488bca52000eaa37fa63b9988e8c487458d9cd5ace6", + "sha256:faf2ee02e6612577ba0181f4347bcbcf591eb122f7841ae5ba233d12c39dcb4d" ], "index": "pypi", "markers": "python_version >= '3.8'", - "version": "==24.1.1" + "version": "==24.2.0" }, "certifi": { "hashes": [ @@ -3070,12 +3070,12 @@ }, "mkdocs-material": { "hashes": [ - "sha256:14563314bbf97da4bfafc69053772341babfaeb3329cde01d3e63cec03997af8", - "sha256:2a429213e83f84eda7a588e2b186316d806aac602b7f93990042f7a1f3d3cf65" + "sha256:635df543c01c25c412d6c22991872267723737d5a2f062490f33b2da1c013c6d", + "sha256:a5d62b73b3b74349e45472bfadc129c871dd2d4add68d84819580597b2f50d5d" ], "index": "pypi", "markers": "python_version >= '3.8'", - "version": "==9.5.8" + "version": "==9.5.9" }, "mkdocs-material-extensions": { "hashes": [ @@ -3386,7 +3386,6 @@ "sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86", "sha256:961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9" ], - "index": "pypi", "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", "version": "==2.8.2" }, @@ -3475,6 +3474,7 @@ "sha256:fd1592b3fdf65fff2ad0004b5e363300ef59ced41c2e6b3a99d4089fa8c5435d", "sha256:fd66fc5d0da6d9815ba2cebeb4205f95818ff4b79c3ebe268e75d961704af52f" ], + "markers": "python_version >= '3.6'", "version": "==6.0.1" }, "pyyaml-env-tag": { @@ -3767,7 +3767,6 @@ "sha256:d00e6be486affb5781468457b21a6cbe848c33ef43f9ea4a73b4882e5f188a44", "sha256:d429c2430c93b7903914e4db9a966c7f2b068dd2ebdd2fa9b9ce094c7d459f33" ], - "index": "pypi", "markers": "python_version >= '3.7'", "version": "==3.0.0" }, diff --git a/docs/configuration.md b/docs/configuration.md index ded699c29..f80e624dc 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -540,8 +540,8 @@ This is for use with self-signed certificates against local IMAP servers. : This variable is used to setup login and signup via social account providers which are compatible with django-allauth. See the corresponding [django-allauth documentation](https://docs.allauth.org/en/0.60.0/socialaccount/providers/index.html) -for a list of provider configurations. You will also likely need to include the relevant Django 'application' inside the -[PAPERLESS_APPS](#PAPERLESS_APPS) setting. +for a list of provider configurations. You will also need to include the relevant Django 'application' inside the +[PAPERLESS_APPS](#PAPERLESS_APPS) setting to activate that specific authentication provider (e.g. `allauth.socialaccount.providers.openid_connect` for the [OIDC Connect provider](https://docs.allauth.org/en/latest/socialaccount/providers/openid_connect.html)). Defaults to None, which does not enable any third party authentication systems. diff --git a/src/documents/barcodes.py b/src/documents/barcodes.py index 4bfb9b791..5bf622651 100644 --- a/src/documents/barcodes.py +++ b/src/documents/barcodes.py @@ -88,64 +88,71 @@ class BarcodePlugin(ConsumeTaskPlugin): self.detect() # Update/overwrite an ASN if possible - located_asn = self.asn - if located_asn is not None: + if ( + settings.CONSUMER_ENABLE_ASN_BARCODE + and (located_asn := self.asn) is not None + ): logger.info(f"Found ASN in barcode: {located_asn}") self.metadata.asn = located_asn # try reading tags from barcodes - if settings.CONSUMER_ENABLE_TAG_BARCODE: - tags = self.tags - if tags is not None and len(tags) > 0: - if self.metadata.tag_ids: - self.metadata.tag_ids += tags - else: - self.metadata.tag_ids = tags - logger.info(f"Found tags in barcode: {tags}") + if ( + settings.CONSUMER_ENABLE_TAG_BARCODE + and (tags := self.tags) is not None + and len(tags) > 0 + ): + if self.metadata.tag_ids: + self.metadata.tag_ids += tags + else: + self.metadata.tag_ids = tags + logger.info(f"Found tags in barcode: {tags}") - separator_pages = self.get_separation_pages() - if not separator_pages: - return "No pages to split on!" + # Lastly attempt to split documents + if settings.CONSUMER_ENABLE_BARCODES: - # We have pages to split against + separator_pages = self.get_separation_pages() + if not separator_pages: + return "No pages to split on!" - # Note this does NOT use the base_temp_dir, as that will be removed - tmp_dir = Path( - tempfile.mkdtemp( - dir=settings.SCRATCH_DIR, - prefix="paperless-barcode-split-", - ), - ).resolve() + # We have pages to split against - from documents import tasks - - # Create the split document tasks - for new_document in self.separate_pages(separator_pages): - copy_file_with_basic_stats(new_document, tmp_dir / new_document.name) - - task = tasks.consume_file.delay( - ConsumableDocument( - # Same source, for templates - source=self.input_doc.source, - mailrule_id=self.input_doc.mailrule_id, - # Can't use same folder or the consume might grab it again - original_file=(tmp_dir / new_document.name).resolve(), + # Note this does NOT use the base_temp_dir, as that will be removed + tmp_dir = Path( + tempfile.mkdtemp( + dir=settings.SCRATCH_DIR, + prefix="paperless-barcode-split-", ), - # All the same metadata - self.metadata, - ) - logger.info(f"Created new task {task.id} for {new_document.name}") + ).resolve() - # This file is now two or more files - self.input_doc.original_file.unlink() + from documents import tasks - msg = "Barcode splitting complete!" + # Create the split document tasks + for new_document in self.separate_pages(separator_pages): + copy_file_with_basic_stats(new_document, tmp_dir / new_document.name) - # Update the progress to complete - self.status_mgr.send_progress(ProgressStatusOptions.SUCCESS, msg, 100, 100) + task = tasks.consume_file.delay( + ConsumableDocument( + # Same source, for templates + source=self.input_doc.source, + mailrule_id=self.input_doc.mailrule_id, + # Can't use same folder or the consume might grab it again + original_file=(tmp_dir / new_document.name).resolve(), + ), + # All the same metadata + self.metadata, + ) + logger.info(f"Created new task {task.id} for {new_document.name}") - # Request the consume task stops - raise StopConsumeTaskError(msg) + # This file is now two or more files + self.input_doc.original_file.unlink() + + msg = "Barcode splitting complete!" + + # Update the progress to complete + self.status_mgr.send_progress(ProgressStatusOptions.SUCCESS, msg, 100, 100) + + # Request the consume task stops + raise StopConsumeTaskError(msg) def cleanup(self) -> None: self.temp_dir.cleanup() diff --git a/src/documents/tests/test_barcodes.py b/src/documents/tests/test_barcodes.py index 3dd6d62ff..732c2e167 100644 --- a/src/documents/tests/test_barcodes.py +++ b/src/documents/tests/test_barcodes.py @@ -402,6 +402,7 @@ class TestBarcode( self.assertEqual(len(documents), 2) + @override_settings(CONSUMER_ENABLE_BARCODES=True) def test_separate_pages_no_list(self): """ GIVEN: