mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-05-01 11:19:32 -05:00
setup placeholder vars once
This commit is contained in:
parent
553eb54317
commit
69a4331d99
@ -884,25 +884,31 @@ def run_workflows(
|
|||||||
doc_url = None
|
doc_url = None
|
||||||
if isinstance(document, Document):
|
if isinstance(document, Document):
|
||||||
doc_url = f"{settings.PAPERLESS_URL}/documents/{document.pk}/"
|
doc_url = f"{settings.PAPERLESS_URL}/documents/{document.pk}/"
|
||||||
|
correspondent = document.correspondent.name if document.correspondent else ""
|
||||||
|
document_type = document.document_type.name if document.document_type else ""
|
||||||
|
owner_username = document.owner.username if document.owner else ""
|
||||||
|
filename = document.original_filename or ""
|
||||||
|
added = timezone.localtime(document.added)
|
||||||
|
created = timezone.localtime(document.created)
|
||||||
subject = parse_w_workflow_placeholders(
|
subject = parse_w_workflow_placeholders(
|
||||||
action.email_subject,
|
action.email_subject,
|
||||||
document.correspondent.name if document.correspondent else "",
|
correspondent,
|
||||||
document.document_type.name if document.document_type else "",
|
document_type,
|
||||||
document.owner.username if document.owner else "",
|
owner_username,
|
||||||
timezone.localtime(document.added),
|
added,
|
||||||
document.original_filename or "",
|
filename,
|
||||||
timezone.localtime(document.created),
|
created,
|
||||||
title,
|
title,
|
||||||
doc_url,
|
doc_url,
|
||||||
)
|
)
|
||||||
body = parse_w_workflow_placeholders(
|
body = parse_w_workflow_placeholders(
|
||||||
action.email_body,
|
action.email_body,
|
||||||
document.correspondent.name if document.correspondent else "",
|
correspondent,
|
||||||
document.document_type.name if document.document_type else "",
|
document_type,
|
||||||
document.owner.username if document.owner else "",
|
owner_username,
|
||||||
timezone.localtime(document.added),
|
added,
|
||||||
document.original_filename or "",
|
filename,
|
||||||
timezone.localtime(document.created),
|
created,
|
||||||
title,
|
title,
|
||||||
doc_url,
|
doc_url,
|
||||||
)
|
)
|
||||||
@ -934,6 +940,12 @@ def run_workflows(
|
|||||||
doc_url = None
|
doc_url = None
|
||||||
if isinstance(document, Document):
|
if isinstance(document, Document):
|
||||||
doc_url = f"{settings.PAPERLESS_URL}/documents/{document.pk}/"
|
doc_url = f"{settings.PAPERLESS_URL}/documents/{document.pk}/"
|
||||||
|
correspondent = document.correspondent.name if document.correspondent else ""
|
||||||
|
document_type = document.document_type.name if document.document_type else ""
|
||||||
|
owner_username = document.owner.username if document.owner else ""
|
||||||
|
filename = document.original_filename or ""
|
||||||
|
added = timezone.localtime(document.added)
|
||||||
|
created = timezone.localtime(document.created)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
data = {}
|
data = {}
|
||||||
@ -942,16 +954,12 @@ def run_workflows(
|
|||||||
for key, value in action.webhook_params.items():
|
for key, value in action.webhook_params.items():
|
||||||
data[key] = parse_w_workflow_placeholders(
|
data[key] = parse_w_workflow_placeholders(
|
||||||
value,
|
value,
|
||||||
document.correspondent.name
|
correspondent,
|
||||||
if document.correspondent
|
document_type,
|
||||||
else "",
|
owner_username,
|
||||||
document.document_type.name
|
added,
|
||||||
if document.document_type
|
filename,
|
||||||
else "",
|
created,
|
||||||
document.owner.username if document.owner else "",
|
|
||||||
timezone.localtime(document.added),
|
|
||||||
document.original_filename or "",
|
|
||||||
timezone.localtime(document.created),
|
|
||||||
title,
|
title,
|
||||||
doc_url,
|
doc_url,
|
||||||
)
|
)
|
||||||
@ -963,12 +971,12 @@ def run_workflows(
|
|||||||
else:
|
else:
|
||||||
data = parse_w_workflow_placeholders(
|
data = parse_w_workflow_placeholders(
|
||||||
action.webhook_body,
|
action.webhook_body,
|
||||||
document.correspondent.name if document.correspondent else "",
|
correspondent,
|
||||||
document.document_type.name if document.document_type else "",
|
document_type,
|
||||||
document.owner.username if document.owner else "",
|
owner_username,
|
||||||
timezone.localtime(document.added),
|
added,
|
||||||
document.original_filename or "",
|
filename,
|
||||||
timezone.localtime(document.created),
|
created,
|
||||||
title,
|
title,
|
||||||
doc_url,
|
doc_url,
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user