Skip to content

A community-supported supercharged document management system: scan, index and archive all your documents

Enhancement: include owner username in post-consumption variables (#7270)

Freddy08e3ca37b0553
diff --git a/docs/advanced_usage.md b/docs/advanced_usage.md
index 0a8c2972f..5488659a2 100644
--- a/docs/advanced_usage.md
+++ b/docs/advanced_usage.md
@@ -187,6 +187,7 @@ variables:
| `DOCUMENT_THUMBNAIL_PATH` | Path to the generated thumbnail |
| `DOCUMENT_DOWNLOAD_URL` | URL for document download |
| `DOCUMENT_THUMBNAIL_URL` | URL for the document thumbnail |
+| `DOCUMENT_OWNER` | Username of the document owner (if any) |
| `DOCUMENT_CORRESPONDENT` | Assigned correspondent (if any) |
| `DOCUMENT_TAGS` | Comma separated list of tags applied (if any) |
| `DOCUMENT_ORIGINAL_FILENAME` | Filename of original document |
diff --git a/scripts/post-consumption-example.sh b/scripts/post-consumption-example.sh
index 6e42b1bc3..154f9df71 100755
--- a/scripts/post-consumption-example.sh
+++ b/scripts/post-consumption-example.sh
@@ -14,6 +14,7 @@ following additional information about it:
* Thumbnail Path: ${DOCUMENT_THUMBNAIL_PATH}
* Download URL: ${DOCUMENT_DOWNLOAD_URL}
* Thumbnail URL: ${DOCUMENT_THUMBNAIL_URL}
+* Owner Name: ${DOCUMENT_OWNER}
* Correspondent: ${DOCUMENT_CORRESPONDENT}
* Tags: ${DOCUMENT_TAGS}
diff --git a/src/documents/consumer.py b/src/documents/consumer.py
index d061a4352..b6d0ea455 100644
--- a/src/documents/consumer.py
+++ b/src/documents/consumer.py
@@ -450,6 +450,9 @@ class ConsumerPlugin(
"document-thumb",
kwargs={"pk": document.pk},
)
+ script_env["DOCUMENT_OWNER"] = (
+ document.owner.get_username() if document.owner else ""
+ )
script_env["DOCUMENT_CORRESPONDENT"] = str(document.correspondent)
script_env["DOCUMENT_TAGS"] = str(
",".join(document.tags.all().values_list("name", flat=True)),