mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-01-16 22:04:21 -06:00
Compare commits
1 Commits
feature-bu
...
feature-95
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7710848a25 |
@@ -597,6 +597,7 @@ The following placeholders are only available for "added" or "updated" triggers
|
|||||||
- `{{created_day}}`: created day
|
- `{{created_day}}`: created day
|
||||||
- `{{created_time}}`: created time in HH:MM format
|
- `{{created_time}}`: created time in HH:MM format
|
||||||
- `{{doc_url}}`: URL to the document in the web UI. Requires the `PAPERLESS_URL` setting to be set.
|
- `{{doc_url}}`: URL to the document in the web UI. Requires the `PAPERLESS_URL` setting to be set.
|
||||||
|
- `{{doc_id}}`: Document ID
|
||||||
|
|
||||||
##### Examples
|
##### Examples
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ def parse_w_workflow_placeholders(
|
|||||||
created: date | None = None,
|
created: date | None = None,
|
||||||
doc_title: str | None = None,
|
doc_title: str | None = None,
|
||||||
doc_url: str | None = None,
|
doc_url: str | None = None,
|
||||||
|
doc_id: int | None = None,
|
||||||
) -> str:
|
) -> str:
|
||||||
"""
|
"""
|
||||||
Available title placeholders for Workflows depend on what has already been assigned,
|
Available title placeholders for Workflows depend on what has already been assigned,
|
||||||
@@ -79,6 +80,8 @@ def parse_w_workflow_placeholders(
|
|||||||
formatting.update({"doc_title": doc_title})
|
formatting.update({"doc_title": doc_title})
|
||||||
if doc_url is not None:
|
if doc_url is not None:
|
||||||
formatting.update({"doc_url": doc_url})
|
formatting.update({"doc_url": doc_url})
|
||||||
|
if doc_id is not None:
|
||||||
|
formatting.update({"doc_id": str(doc_id)})
|
||||||
|
|
||||||
logger.debug(f"Parsing Workflow Jinja template: {text}")
|
logger.debug(f"Parsing Workflow Jinja template: {text}")
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -3298,7 +3298,7 @@ class TestWorkflows(
|
|||||||
)
|
)
|
||||||
webhook_action = WorkflowActionWebhook.objects.create(
|
webhook_action = WorkflowActionWebhook.objects.create(
|
||||||
use_params=False,
|
use_params=False,
|
||||||
body="Test message: {{doc_url}}",
|
body="Test message: {{doc_url}} with id {{doc_id}}",
|
||||||
url="http://paperless-ngx.com",
|
url="http://paperless-ngx.com",
|
||||||
include_document=False,
|
include_document=False,
|
||||||
)
|
)
|
||||||
@@ -3328,7 +3328,10 @@ class TestWorkflows(
|
|||||||
|
|
||||||
mock_post.assert_called_once_with(
|
mock_post.assert_called_once_with(
|
||||||
url="http://paperless-ngx.com",
|
url="http://paperless-ngx.com",
|
||||||
data=f"Test message: http://localhost:8000/paperless/documents/{doc.id}/",
|
data=(
|
||||||
|
f"Test message: http://localhost:8000/paperless/documents/{doc.id}/"
|
||||||
|
f" with id {doc.id}"
|
||||||
|
),
|
||||||
headers={},
|
headers={},
|
||||||
files=None,
|
files=None,
|
||||||
as_json=False,
|
as_json=False,
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ def build_workflow_action_context(
|
|||||||
"current_filename": document.filename or "",
|
"current_filename": document.filename or "",
|
||||||
"added": timezone.localtime(document.added),
|
"added": timezone.localtime(document.added),
|
||||||
"created": document.created,
|
"created": document.created,
|
||||||
|
"id": document.pk,
|
||||||
}
|
}
|
||||||
|
|
||||||
correspondent_obj = (
|
correspondent_obj = (
|
||||||
@@ -75,6 +76,7 @@ def build_workflow_action_context(
|
|||||||
"current_filename": filename,
|
"current_filename": filename,
|
||||||
"added": timezone.localtime(timezone.now()),
|
"added": timezone.localtime(timezone.now()),
|
||||||
"created": overrides.created if overrides else None,
|
"created": overrides.created if overrides else None,
|
||||||
|
"id": "",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -109,6 +111,7 @@ def execute_email_action(
|
|||||||
context["created"],
|
context["created"],
|
||||||
context["title"],
|
context["title"],
|
||||||
context["doc_url"],
|
context["doc_url"],
|
||||||
|
context["id"],
|
||||||
)
|
)
|
||||||
if action.email.subject
|
if action.email.subject
|
||||||
else ""
|
else ""
|
||||||
@@ -125,6 +128,7 @@ def execute_email_action(
|
|||||||
context["created"],
|
context["created"],
|
||||||
context["title"],
|
context["title"],
|
||||||
context["doc_url"],
|
context["doc_url"],
|
||||||
|
context["id"],
|
||||||
)
|
)
|
||||||
if action.email.body
|
if action.email.body
|
||||||
else ""
|
else ""
|
||||||
@@ -203,6 +207,7 @@ def execute_webhook_action(
|
|||||||
context["created"],
|
context["created"],
|
||||||
context["title"],
|
context["title"],
|
||||||
context["doc_url"],
|
context["doc_url"],
|
||||||
|
context["id"],
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(
|
logger.error(
|
||||||
@@ -221,6 +226,7 @@ def execute_webhook_action(
|
|||||||
context["created"],
|
context["created"],
|
||||||
context["title"],
|
context["title"],
|
||||||
context["doc_url"],
|
context["doc_url"],
|
||||||
|
context["id"],
|
||||||
)
|
)
|
||||||
headers = {}
|
headers = {}
|
||||||
if action.webhook.headers:
|
if action.webhook.headers:
|
||||||
|
|||||||
@@ -55,6 +55,9 @@ def apply_assignment_to_document(
|
|||||||
document.original_filename or "",
|
document.original_filename or "",
|
||||||
document.filename or "",
|
document.filename or "",
|
||||||
document.created,
|
document.created,
|
||||||
|
"", # dont pass the title to avoid recursion
|
||||||
|
"", # no urls in titles
|
||||||
|
document.pk,
|
||||||
)
|
)
|
||||||
except Exception: # pragma: no cover
|
except Exception: # pragma: no cover
|
||||||
logger.exception(
|
logger.exception(
|
||||||
|
|||||||
Reference in New Issue
Block a user