mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-10-24 03:26:11 -05:00
54 lines
1.6 KiB
Python
54 lines
1.6 KiB
Python
# 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():
|
|
if not WorkflowAction.assign_title:
|
|
continue
|
|
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(
|
|
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,
|
|
),
|
|
]
|