Fixes the barcodes always splitting on ASNs, even if splitting was disabled

This commit is contained in:
Trenton H 2024-02-12 11:18:23 -08:00
parent 1197437750
commit d90ec5bb7f
2 changed files with 55 additions and 45 deletions

View File

@ -88,21 +88,30 @@ 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)
and located_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 (
settings.CONSUMER_ENABLE_TAG_BARCODE
and (tags := self.tags)
and 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}")
# Lastly attempt to split documents
if settings.CONSUMER_ENABLE_BARCODES:
separator_pages = self.get_separation_pages()
if not separator_pages:
return "No pages to split on!"

View File

@ -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: