2025-10-22 11:40:13 -07:00
|
|
|
# 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():
|
2025-10-22 12:17:06 -07:00
|
|
|
if not WorkflowAction.assign_title:
|
|
|
|
|
continue
|
2025-10-22 11:40:13 -07:00
|
|
|
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", "1072_workflowtrigger_filter_custom_field_query_and_more"),
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
operations = [
|
|
|
|
|
migrations.AlterField(
|
2025-10-23 15:29:49 -07:00
|
|
|
model_name="workflowaction",
|
2025-10-22 11:40:13 -07:00
|
|
|
name="assign_title",
|
|
|
|
|
field=models.TextField(
|
|
|
|
|
blank=True,
|
2025-10-23 15:29:49 -07:00
|
|
|
help_text="Assign a document title, must be a Jinja2 template, see documentation.",
|
|
|
|
|
null=True,
|
|
|
|
|
verbose_name="assign title",
|
2025-10-22 11:40:13 -07:00
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
migrations.RunPython(
|
|
|
|
|
convert_from_format_to_template,
|
|
|
|
|
migrations.RunPython.noop,
|
|
|
|
|
),
|
|
|
|
|
]
|