From: Trenton H <797416+stumpylog@users.noreply.github.com> Date: Thu, 16 Nov 2023 00:23:38 +0000 (-0800) Subject: Handles the case where other might have a None field as well (#4598) X-Git-Tag: v2.0.0~3^2~20 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=07989bc2facd7c5777d37fd90fc8c5c0ad1018b6;p=thirdparty%2Fpaperless-ngx.git Handles the case where other might have a None field as well (#4598) --- diff --git a/src/documents/data_models.py b/src/documents/data_models.py index 7dcfe4401b..29a23fa7aa 100644 --- a/src/documents/data_models.py +++ b/src/documents/data_models.py @@ -48,31 +48,32 @@ class DocumentMetadataOverrides: self.storage_path_id = other.storage_path_id 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: + elif other.tag_ids is not None: self.tag_ids.extend(other.tag_ids) + if self.view_users is None: self.view_users = other.view_users - else: + elif other.view_users is not None: self.view_users.extend(other.view_users) + if self.view_groups is None: self.view_groups = other.view_groups - else: + elif other.view_groups is not None: self.view_groups.extend(other.view_groups) + if self.change_users is None: self.change_users = other.change_users - else: + elif other.change_users is not None: self.change_users.extend(other.change_users) + if self.change_groups is None: self.change_groups = other.change_groups - else: - self.change_groups = [ - *self.change_groups, - *other.change_groups, - ] + elif other.change_groups is not None: + self.change_groups.extend(other.change_groups) return self diff --git a/src/paperless_mail/mail.py b/src/paperless_mail/mail.py index f3ebc35dfb..2179b8c908 100644 --- a/src/paperless_mail/mail.py +++ b/src/paperless_mail/mail.py @@ -617,7 +617,7 @@ class MailAccountHandler(LoggingMixin): f"{len(message.attachments)} attachment(s)", ) - tag_ids = [tag.id for tag in rule.assign_tags.all()] + tag_ids: list[int] = [tag.id for tag in rule.assign_tags.all()] doc_type = rule.assign_document_type if (