Small rework to show names instead of numbers for document source

This commit is contained in:
Trenton Holmes 2023-09-21 07:01:54 -07:00 committed by shamoon
parent f87ff194cb
commit ccda7095a0
3 changed files with 9 additions and 7 deletions

View File

@ -49,22 +49,23 @@ class DocumentMetadataOverrides:
if self.owner_id is None: if self.owner_id is None:
self.owner_id = other.owner_id self.owner_id = other.owner_id
# merge # merge
# TODO: Handle the case where other is also None
if self.tag_ids is None: if self.tag_ids is None:
self.tag_ids = other.tag_ids self.tag_ids = other.tag_ids
else: else:
self.tag_ids = [*self.tag_ids, *other.tag_ids] self.tag_ids.extend(other.tag_ids)
if self.view_users is None: if self.view_users is None:
self.view_users = other.view_users self.view_users = other.view_users
else: else:
self.view_users = [*self.view_users, *other.view_users] self.view_users.extend(other.view_users)
if self.view_groups is None: if self.view_groups is None:
self.view_groups = other.view_groups self.view_groups = other.view_groups
else: else:
self.view_groups = [*self.view_groups, *other.view_groups] self.view_groups.extend(other.view_groups)
if self.change_users is None: if self.change_users is None:
self.change_users = other.change_users self.change_users = other.change_users
else: else:
self.change_users = [*self.change_users, *other.change_users] self.change_users.extend(other.change_users)
if self.change_groups is None: if self.change_groups is None:
self.change_groups = other.change_groups self.change_groups = other.change_groups
else: else:

View File

@ -4,6 +4,7 @@ from fnmatch import fnmatch
from documents.classifier import DocumentClassifier from documents.classifier import DocumentClassifier
from documents.data_models import ConsumableDocument from documents.data_models import ConsumableDocument
from documents.data_models import DocumentSource
from documents.models import ConsumptionTemplate from documents.models import ConsumptionTemplate
from documents.models import Correspondent from documents.models import Correspondent
from documents.models import Document from documents.models import Document
@ -252,8 +253,8 @@ def document_matches_template(
# Document source vs template source # Document source vs template source
if document.source not in [int(x) for x in list(template.sources)]: if document.source not in [int(x) for x in list(template.sources)]:
log_match_failure( log_match_failure(
f"Document source {document.source} not in" f"Document source {document.source.name} not in"
f" {[int(x) for x in list(template.sources)]}", f" {[DocumentSource(int(x)).name for x in template.sources]}",
) )
return False return False

View File

@ -472,5 +472,5 @@ class TestConsumptionTemplates(DirectoriesMixin, FileSystemAssertsMixin, TestCas
expected_str = f"Document did not match template {ct}" expected_str = f"Document did not match template {ct}"
self.assertIn(expected_str, cm.output[0]) 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]) self.assertIn(expected_str, cm.output[1])