A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
Fail consumption when duplicate ASN is given (rather than just logging warning)
Peter Kappelt64752f6b57d2
diff --git a/src-ui/src/app/services/consumer-status.service.ts b/src-ui/src/app/services/consumer-status.service.tsindex 176227bef..51c4292b4 100644--- a/src-ui/src/app/services/consumer-status.service.ts+++ b/src-ui/src/app/services/consumer-status.service.ts@@ -13,6 +13,7 @@ export enum FileStatusPhase {export const FILE_STATUS_MESSAGES = {document_already_exists: $localize`Document already exists.`,+ asn_already_exists: $localize`Document with ASN already exists.`,file_not_found: $localize`File not found.`,pre_consume_script_not_found: $localize`:Pre-Consume is a term that appears like that in the documentation as well and does not need a specific translation:Pre-consume script does not exist.`,pre_consume_script_error: $localize`:Pre-Consume is a term that appears like that in the documentation as well and does not need a specific translation:Error while executing pre-consume script.`,diff --git a/src/documents/consumer.py b/src/documents/consumer.pyindex aec215e7c..12552bf67 100644--- a/src/documents/consumer.py+++ b/src/documents/consumer.py@@ -39,6 +39,7 @@ class ConsumerError(Exception):MESSAGE_DOCUMENT_ALREADY_EXISTS = "document_already_exists"+MESSAGE_ASN_ALREADY_EXISTS = "asn_already_exists"MESSAGE_FILE_NOT_FOUND = "file_not_found"MESSAGE_PRE_CONSUME_SCRIPT_NOT_FOUND = "pre_consume_script_not_found"MESSAGE_PRE_CONSUME_SCRIPT_ERROR = "pre_consume_script_error"@@ -139,12 +140,10 @@ class Consumer(LoggingMixin):# check not necessary in case no ASN gets setreturnif Document.objects.filter(archive_serial_number=self.override_asn).exists():- self.log(- "warning",- f"A document with ASN {self.override_asn} already exists. "- + "No ASN will be set!",+ self._fail(+ MESSAGE_ASN_ALREADY_EXISTS,+ f"Not consuming {self.filename}: Given ASN already" f"exists!",)- self.override_asn = Nonedef run_pre_consume_script(self):if not settings.PRE_CONSUME_SCRIPT: