Merge branch 'dev' into dev

This commit is contained in:
Trenton H 2023-10-30 08:52:26 -07:00 committed by GitHub
commit 5baa201447
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 32 additions and 10 deletions

View File

@ -22,6 +22,13 @@ env:
jobs: jobs:
pre-commit: pre-commit:
# We want to run on external PRs, but not on our own internal PRs as they'll be run
# by the push to the branch. Without this if check, checks are duplicated since
# internal PRs match both the push and pull_request events.
if:
github.event_name == 'push' || github.event.pull_request.head.repo.full_name !=
github.repository
name: Linting Checks name: Linting Checks
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
steps: steps:

View File

@ -254,6 +254,10 @@ a.btn-link:focus-visible,
min-height: calc(1.5em + 0.75rem + 5px); min-height: calc(1.5em + 0.75rem + 5px);
line-height: 1.5; line-height: 1.5;
.ng-select-container {
border-radius: $border-radius;
}
.ng-select-container .ng-value-container .ng-input { .ng-select-container .ng-value-container .ng-input {
top: 7px; top: 7px;
} }
@ -311,6 +315,7 @@ textarea,
color: var(--bs-body-color); color: var(--bs-body-color);
background-color: var(--bs-body-bg); background-color: var(--bs-body-bg);
border-color: var(--bs-border-color); border-color: var(--bs-border-color);
font-size: 0.875rem;
&:focus { &:focus {
background-color: var(--pngx-bg-darker); background-color: var(--pngx-bg-darker);

View File

@ -32,7 +32,7 @@ except ImportError: # pragma: nocover
logger = logging.getLogger("paperless.management.consumer") logger = logging.getLogger("paperless.management.consumer")
def _tags_from_path(filepath) -> set[Tag]: def _tags_from_path(filepath) -> list[int]:
""" """
Walk up the directory tree from filepath to CONSUMPTION_DIR Walk up the directory tree from filepath to CONSUMPTION_DIR
and get or create Tag IDs for every directory. and get or create Tag IDs for every directory.
@ -47,7 +47,7 @@ def _tags_from_path(filepath) -> set[Tag]:
Tag.objects.get_or_create(name__iexact=part, defaults={"name": part})[0].pk, Tag.objects.get_or_create(name__iexact=part, defaults={"name": part})[0].pk,
) )
return tag_ids return list(tag_ids)
def _is_ignored(filepath: str) -> bool: def _is_ignored(filepath: str) -> bool:

View File

@ -8,6 +8,7 @@ import traceback
from datetime import date from datetime import date
from datetime import timedelta from datetime import timedelta
from fnmatch import fnmatch from fnmatch import fnmatch
from typing import Optional
from typing import Union from typing import Union
import magic import magic
@ -21,6 +22,7 @@ from django.utils.timezone import is_naive
from django.utils.timezone import make_aware from django.utils.timezone import make_aware
from imap_tools import AND from imap_tools import AND
from imap_tools import NOT from imap_tools import NOT
from imap_tools import MailAttachment
from imap_tools import MailBox from imap_tools import MailBox
from imap_tools import MailboxFolderSelectError from imap_tools import MailboxFolderSelectError
from imap_tools import MailBoxUnencrypted from imap_tools import MailBoxUnencrypted
@ -422,14 +424,19 @@ class MailAccountHandler(LoggingMixin):
logging_name = "paperless_mail" logging_name = "paperless_mail"
def _correspondent_from_name(self, name): def _correspondent_from_name(self, name: str) -> Optional[Correspondent]:
try: try:
return Correspondent.objects.get_or_create(name=name)[0] return Correspondent.objects.get_or_create(name=name)[0]
except DatabaseError as e: except DatabaseError as e:
self.log.error(f"Error while retrieving correspondent {name}: {e}") self.log.error(f"Error while retrieving correspondent {name}: {e}")
return None return None
def _get_title(self, message, att, rule): def _get_title(
self,
message: MailMessage,
att: MailAttachment,
rule: MailRule,
) -> Optional[str]:
if rule.assign_title_from == MailRule.TitleSource.FROM_SUBJECT: if rule.assign_title_from == MailRule.TitleSource.FROM_SUBJECT:
return message.subject return message.subject
@ -444,7 +451,11 @@ class MailAccountHandler(LoggingMixin):
"Unknown title selector.", "Unknown title selector.",
) # pragma: nocover ) # pragma: nocover
def _get_correspondent(self, message: MailMessage, rule): def _get_correspondent(
self,
message: MailMessage,
rule: MailRule,
) -> Optional[Correspondent]:
c_from = rule.assign_correspondent_from c_from = rule.assign_correspondent_from
if c_from == MailRule.CorrespondentSource.FROM_NOTHING: if c_from == MailRule.CorrespondentSource.FROM_NOTHING:
@ -606,7 +617,6 @@ class MailAccountHandler(LoggingMixin):
f"{len(message.attachments)} attachment(s)", f"{len(message.attachments)} attachment(s)",
) )
correspondent = self._get_correspondent(message, rule)
tag_ids = [tag.id for tag in rule.assign_tags.all()] tag_ids = [tag.id for tag in rule.assign_tags.all()]
doc_type = rule.assign_document_type doc_type = rule.assign_document_type
@ -617,7 +627,6 @@ class MailAccountHandler(LoggingMixin):
processed_elements += self._process_eml( processed_elements += self._process_eml(
message, message,
rule, rule,
correspondent,
tag_ids, tag_ids,
doc_type, doc_type,
) )
@ -629,7 +638,6 @@ class MailAccountHandler(LoggingMixin):
processed_elements += self._process_attachments( processed_elements += self._process_attachments(
message, message,
rule, rule,
correspondent,
tag_ids, tag_ids,
doc_type, doc_type,
) )
@ -640,7 +648,6 @@ class MailAccountHandler(LoggingMixin):
self, self,
message: MailMessage, message: MailMessage,
rule: MailRule, rule: MailRule,
correspondent,
tag_ids, tag_ids,
doc_type, doc_type,
): ):
@ -669,6 +676,8 @@ class MailAccountHandler(LoggingMixin):
# as this is system dependent otherwise # as this is system dependent otherwise
continue continue
correspondent = self._get_correspondent(message, rule)
title = self._get_title(message, att, rule) title = self._get_title(message, att, rule)
# don't trust the content type of the attachment. Could be # don't trust the content type of the attachment. Could be
@ -750,7 +759,6 @@ class MailAccountHandler(LoggingMixin):
self, self,
message: MailMessage, message: MailMessage,
rule: MailRule, rule: MailRule,
correspondent,
tag_ids, tag_ids,
doc_type, doc_type,
): ):
@ -781,6 +789,8 @@ class MailAccountHandler(LoggingMixin):
f.write(message.obj.as_bytes()) f.write(message.obj.as_bytes())
correspondent = self._get_correspondent(message, rule)
self.log.info( self.log.info(
f"Rule {rule}: " f"Rule {rule}: "
f"Consuming eml from mail " f"Consuming eml from mail "