Enhancement: jinja template support for workflow title assignment (#10700)

---------

Co-authored-by: Trenton Holmes <797416+stumpylog@users.noreply.github.com>
Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com>
This commit is contained in:
sidey79
2025-09-11 15:56:16 +02:00
committed by GitHub
parent 84942a4e69
commit 9e11e7fd05
12 changed files with 825 additions and 300 deletions

View File

@@ -0,0 +1,51 @@
# Generated by Django 5.2.5 on 2025-08-27 22:02
import logging
from django.db import migrations
from django.db import models
from django.db import transaction
from documents.templating.utils import convert_format_str_to_template_format
logger = logging.getLogger("paperless.migrations")
def convert_from_format_to_template(apps, schema_editor):
WorkflowActions = apps.get_model("documents", "WorkflowAction")
with transaction.atomic():
for WorkflowAction in WorkflowActions.objects.all():
WorkflowAction.assign_title = convert_format_str_to_template_format(
WorkflowAction.assign_title,
)
logger.debug(
"Converted WorkflowAction id %d title to template format: %s",
WorkflowAction.id,
WorkflowAction.assign_title,
)
WorkflowAction.save()
class Migration(migrations.Migration):
dependencies = [
("documents", "1068_alter_document_created"),
]
operations = [
migrations.AlterField(
model_name="WorkflowAction",
name="assign_title",
field=models.TextField(
null=True,
blank=True,
help_text=(
"Assign a document title, can be a JINJA2 template, "
"see documentation.",
),
),
),
migrations.RunPython(
convert_from_format_to_template,
migrations.RunPython.noop,
),
]