mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-10-20 03:06:10 -05:00
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:
@@ -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,
|
||||
),
|
||||
]
|
Reference in New Issue
Block a user