mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-11-03 03:16:10 -06:00 
			
		
		
		
	Enhancement: include current filename placeholder in workflows (#8319)
Co-authored-by: Trenton H <797416+stumpylog@users.noreply.github.com> Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com>
This commit is contained in:
		@@ -439,6 +439,7 @@ applied. You can use the following placeholders with any trigger type:
 | 
			
		||||
-   `{added_day}`: added day
 | 
			
		||||
-   `{added_time}`: added time in HH:MM format
 | 
			
		||||
-   `{original_filename}`: original file name without extension
 | 
			
		||||
-   `{filename}`: current file name without extension
 | 
			
		||||
 | 
			
		||||
The following placeholders are only available for "added" or "updated" triggers
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -673,6 +673,7 @@ class ConsumerPlugin(
 | 
			
		||||
            owner_username,
 | 
			
		||||
            local_added,
 | 
			
		||||
            self.filename,
 | 
			
		||||
            self.filename,
 | 
			
		||||
        )
 | 
			
		||||
 | 
			
		||||
    def _store(
 | 
			
		||||
 
 | 
			
		||||
@@ -1917,6 +1917,7 @@ class WorkflowActionSerializer(serializers.ModelSerializer):
 | 
			
		||||
                        added_time="",
 | 
			
		||||
                        owner_username="",
 | 
			
		||||
                        original_filename="",
 | 
			
		||||
                        filename="",
 | 
			
		||||
                        created="",
 | 
			
		||||
                        created_year="",
 | 
			
		||||
                        created_year_short="",
 | 
			
		||||
 
 | 
			
		||||
@@ -656,6 +656,7 @@ def run_workflows(
 | 
			
		||||
                        document.owner.username if document.owner else "",
 | 
			
		||||
                        timezone.localtime(document.added),
 | 
			
		||||
                        document.original_filename or "",
 | 
			
		||||
                        document.filename or "",
 | 
			
		||||
                        timezone.localtime(document.created),
 | 
			
		||||
                    )
 | 
			
		||||
                except Exception:
 | 
			
		||||
@@ -926,6 +927,7 @@ def run_workflows(
 | 
			
		||||
        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 ""
 | 
			
		||||
        current_filename = document.filename or ""
 | 
			
		||||
        added = timezone.localtime(document.added)
 | 
			
		||||
        created = timezone.localtime(document.created)
 | 
			
		||||
        subject = parse_w_workflow_placeholders(
 | 
			
		||||
@@ -935,6 +937,7 @@ def run_workflows(
 | 
			
		||||
            owner_username,
 | 
			
		||||
            added,
 | 
			
		||||
            filename,
 | 
			
		||||
            current_filename,
 | 
			
		||||
            created,
 | 
			
		||||
            title,
 | 
			
		||||
            doc_url,
 | 
			
		||||
@@ -946,6 +949,7 @@ def run_workflows(
 | 
			
		||||
            owner_username,
 | 
			
		||||
            added,
 | 
			
		||||
            filename,
 | 
			
		||||
            current_filename,
 | 
			
		||||
            created,
 | 
			
		||||
            title,
 | 
			
		||||
            doc_url,
 | 
			
		||||
@@ -982,6 +986,7 @@ def run_workflows(
 | 
			
		||||
        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 ""
 | 
			
		||||
        current_filename = document.filename or ""
 | 
			
		||||
        added = timezone.localtime(document.added)
 | 
			
		||||
        created = timezone.localtime(document.created)
 | 
			
		||||
 | 
			
		||||
@@ -997,6 +1002,7 @@ def run_workflows(
 | 
			
		||||
                            owner_username,
 | 
			
		||||
                            added,
 | 
			
		||||
                            filename,
 | 
			
		||||
                            current_filename,
 | 
			
		||||
                            created,
 | 
			
		||||
                            title,
 | 
			
		||||
                            doc_url,
 | 
			
		||||
@@ -1014,6 +1020,7 @@ def run_workflows(
 | 
			
		||||
                    owner_username,
 | 
			
		||||
                    added,
 | 
			
		||||
                    filename,
 | 
			
		||||
                    current_filename,
 | 
			
		||||
                    created,
 | 
			
		||||
                    title,
 | 
			
		||||
                    doc_url,
 | 
			
		||||
 
 | 
			
		||||
@@ -9,6 +9,7 @@ def parse_w_workflow_placeholders(
 | 
			
		||||
    owner_username: str,
 | 
			
		||||
    local_added: datetime,
 | 
			
		||||
    original_filename: str,
 | 
			
		||||
    filename: str,
 | 
			
		||||
    created: datetime | None = None,
 | 
			
		||||
    doc_title: str | None = None,
 | 
			
		||||
    doc_url: str | None = None,
 | 
			
		||||
@@ -31,6 +32,7 @@ def parse_w_workflow_placeholders(
 | 
			
		||||
        "added_time": local_added.strftime("%H:%M"),
 | 
			
		||||
        "owner_username": owner_username,
 | 
			
		||||
        "original_filename": Path(original_filename).stem,
 | 
			
		||||
        "filename": Path(filename).stem,
 | 
			
		||||
    }
 | 
			
		||||
    if created is not None:
 | 
			
		||||
        formatting.update(
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user