mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-05-09 11:59:27 -05:00
Implement suggestions in PR
This commit is contained in:
parent
247d2fcae1
commit
96d1a43da7
@ -61,19 +61,19 @@ const CONSUMPTION_SCOPE_OPTIONS = [
|
|||||||
|
|
||||||
const PDF_LAYOUT_OPTIONS = [
|
const PDF_LAYOUT_OPTIONS = [
|
||||||
{
|
{
|
||||||
id: MailRulePdfLayout.Text_Html,
|
id: MailRulePdfLayout.TextHtml,
|
||||||
name: $localize`Text, then HTML`,
|
name: $localize`Text, then HTML`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: MailRulePdfLayout.Html_Text,
|
id: MailRulePdfLayout.HtmlText,
|
||||||
name: $localize`HTML, then text`,
|
name: $localize`HTML, then text`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: MailRulePdfLayout.Html_only,
|
id: MailRulePdfLayout.HtmlOnly,
|
||||||
name: $localize`HTML only`,
|
name: $localize`HTML only`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: MailRulePdfLayout.Text_only,
|
id: MailRulePdfLayout.TextOnly,
|
||||||
name: $localize`Text only`,
|
name: $localize`Text only`,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
@ -204,7 +204,7 @@ export class MailRuleEditDialogComponent extends EditDialogComponent<MailRule> {
|
|||||||
filter_attachment_filename_exclude: new FormControl(null),
|
filter_attachment_filename_exclude: new FormControl(null),
|
||||||
maximum_age: new FormControl(null),
|
maximum_age: new FormControl(null),
|
||||||
attachment_type: new FormControl(MailFilterAttachmentType.Attachments),
|
attachment_type: new FormControl(MailFilterAttachmentType.Attachments),
|
||||||
pdf_layout: new FormControl(MailRulePdfLayout.Text_Html),
|
pdf_layout: new FormControl(MailRulePdfLayout.TextHtml),
|
||||||
consumption_scope: new FormControl(MailRuleConsumptionScope.Attachments),
|
consumption_scope: new FormControl(MailRuleConsumptionScope.Attachments),
|
||||||
order: new FormControl(null),
|
order: new FormControl(null),
|
||||||
action: new FormControl(MailAction.MarkRead),
|
action: new FormControl(MailAction.MarkRead),
|
||||||
|
@ -12,10 +12,10 @@ export enum MailRuleConsumptionScope {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export enum MailRulePdfLayout {
|
export enum MailRulePdfLayout {
|
||||||
Text_Html = 1,
|
TextHtml = 1,
|
||||||
Html_Text = 2,
|
HtmlText = 2,
|
||||||
Html_only = 3,
|
HtmlOnly = 3,
|
||||||
Text_only = 4,
|
TextOnly = 4,
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum MailAction {
|
export enum MailAction {
|
||||||
|
@ -127,7 +127,7 @@ class MailDocumentParser(DocumentParser):
|
|||||||
document_path: Path,
|
document_path: Path,
|
||||||
mime_type: str,
|
mime_type: str,
|
||||||
file_name=None,
|
file_name=None,
|
||||||
mailrule: int | None = None,
|
mailrule_id: int | None = None,
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
Parses the given .eml into formatted text, based on the decoded email.
|
Parses the given .eml into formatted text, based on the decoded email.
|
||||||
@ -187,8 +187,8 @@ class MailDocumentParser(DocumentParser):
|
|||||||
self.date = mail.date
|
self.date = mail.date
|
||||||
|
|
||||||
self.log.debug("Creating a PDF from the email")
|
self.log.debug("Creating a PDF from the email")
|
||||||
if mailrule:
|
if mailrule_id:
|
||||||
rule = MailRule.objects.get(pk=mailrule)
|
rule = MailRule.objects.get(pk=mailrule_id)
|
||||||
self.archive_path = self.generate_pdf(mail, rule.pdf_layout)
|
self.archive_path = self.generate_pdf(mail, rule.pdf_layout)
|
||||||
else:
|
else:
|
||||||
self.archive_path = self.generate_pdf(mail)
|
self.archive_path = self.generate_pdf(mail)
|
||||||
@ -266,15 +266,13 @@ class MailDocumentParser(DocumentParser):
|
|||||||
route.pdf_format(pdf_a_format)
|
route.pdf_format(pdf_a_format)
|
||||||
|
|
||||||
match pdf_layout:
|
match pdf_layout:
|
||||||
case MailRule.PdfLayout.TEXT_HTML:
|
|
||||||
route.merge([mail_pdf_file, pdf_of_html_content])
|
|
||||||
case MailRule.PdfLayout.HTML_TEXT:
|
case MailRule.PdfLayout.HTML_TEXT:
|
||||||
route.merge([pdf_of_html_content, mail_pdf_file])
|
route.merge([pdf_of_html_content, mail_pdf_file])
|
||||||
case MailRule.PdfLayout.HTML_ONLY:
|
case MailRule.PdfLayout.HTML_ONLY:
|
||||||
route.merge([pdf_of_html_content])
|
route.merge([pdf_of_html_content])
|
||||||
case MailRule.PdfLayout.TEXT_ONLY:
|
case MailRule.PdfLayout.TEXT_ONLY:
|
||||||
route.merge([mail_pdf_file])
|
route.merge([mail_pdf_file])
|
||||||
case _:
|
case MailRule.PdfLayout.TEXT_HTML | _:
|
||||||
route.merge([mail_pdf_file, pdf_of_html_content])
|
route.merge([mail_pdf_file, pdf_of_html_content])
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user