diff --git a/src/documents/data_models.py b/src/documents/data_models.py index 08282889f..3a1a2d95e 100644 --- a/src/documents/data_models.py +++ b/src/documents/data_models.py @@ -49,22 +49,23 @@ class DocumentMetadataOverrides: if self.owner_id is None: self.owner_id = other.owner_id # merge + # TODO: Handle the case where other is also None if self.tag_ids is None: self.tag_ids = other.tag_ids else: - self.tag_ids = [*self.tag_ids, *other.tag_ids] + self.tag_ids.extend(other.tag_ids) if self.view_users is None: self.view_users = other.view_users else: - self.view_users = [*self.view_users, *other.view_users] + self.view_users.extend(other.view_users) if self.view_groups is None: self.view_groups = other.view_groups else: - self.view_groups = [*self.view_groups, *other.view_groups] + self.view_groups.extend(other.view_groups) if self.change_users is None: self.change_users = other.change_users else: - self.change_users = [*self.change_users, *other.change_users] + self.change_users.extend(other.change_users) if self.change_groups is None: self.change_groups = other.change_groups else: diff --git a/src/documents/matching.py b/src/documents/matching.py index 70cb86218..9c6e11ca7 100644 --- a/src/documents/matching.py +++ b/src/documents/matching.py @@ -4,6 +4,7 @@ from fnmatch import fnmatch from documents.classifier import DocumentClassifier from documents.data_models import ConsumableDocument +from documents.data_models import DocumentSource from documents.models import ConsumptionTemplate from documents.models import Correspondent from documents.models import Document @@ -252,8 +253,8 @@ def document_matches_template( # Document source vs template source if document.source not in [int(x) for x in list(template.sources)]: log_match_failure( - f"Document source {document.source} not in" - f" {[int(x) for x in list(template.sources)]}", + f"Document source {document.source.name} not in" + f" {[DocumentSource(int(x)).name for x in template.sources]}", ) return False diff --git a/src/documents/tests/test_consumption_templates.py b/src/documents/tests/test_consumption_templates.py index 629c83e62..23cda7c1e 100644 --- a/src/documents/tests/test_consumption_templates.py +++ b/src/documents/tests/test_consumption_templates.py @@ -472,5 +472,5 @@ class TestConsumptionTemplates(DirectoriesMixin, FileSystemAssertsMixin, TestCas expected_str = f"Document did not match template {ct}" self.assertIn(expected_str, cm.output[0]) - expected_str = f"Document source {DocumentSource.ApiUpload} not in [{DocumentSource.ConsumeFolder}, {DocumentSource.MailFetch}]" + expected_str = f"Document source {DocumentSource.ApiUpload.name} not in ['{DocumentSource.ConsumeFolder.name}', '{DocumentSource.MailFetch.name}']" self.assertIn(expected_str, cm.output[1])