mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-08-16 00:36:22 +00:00
Basic backend migration, frontend UI. Mostly works
[ci skip]
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
# Generated by Django 5.1.6 on 2025-03-01 04:49
|
||||
|
||||
from django.db import migrations
|
||||
from django.db import models
|
||||
|
||||
import documents.models
|
||||
|
||||
|
||||
def convert_assign_custom_fields(apps, schema_editor):
|
||||
# Convert the old assign_custom_fields ManyToManyField to the new assign_custom_fields_w_values JSONField
|
||||
WorkflowAction = apps.get_model("documents", "WorkflowAction")
|
||||
for workflow_action in WorkflowAction.objects.all():
|
||||
if workflow_action.assign_custom_fields.exists():
|
||||
workflow_action.assign_custom_fields_w_values = {
|
||||
custom_field.id: None
|
||||
for custom_field in workflow_action.assign_custom_fields.all()
|
||||
}
|
||||
workflow_action.save()
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("documents", "1063_paperlesstask_type_alter_paperlesstask_task_name_and_more"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="workflowaction",
|
||||
name="assign_custom_fields_w_values",
|
||||
field=models.JSONField(
|
||||
blank=True,
|
||||
help_text="assign these custom fields, with optional values",
|
||||
null=True,
|
||||
verbose_name=documents.models.CustomField,
|
||||
),
|
||||
),
|
||||
migrations.RunPython(convert_assign_custom_fields, migrations.RunPython.noop),
|
||||
migrations.RemoveField(
|
||||
model_name="workflowaction",
|
||||
name="assign_custom_fields",
|
||||
),
|
||||
]
|
@@ -1264,11 +1264,13 @@ class WorkflowAction(models.Model):
|
||||
verbose_name=_("grant change permissions to these groups"),
|
||||
)
|
||||
|
||||
assign_custom_fields = models.ManyToManyField(
|
||||
assign_custom_fields_w_values = models.JSONField(
|
||||
CustomField,
|
||||
blank=True,
|
||||
related_name="+",
|
||||
verbose_name=_("assign these custom fields"),
|
||||
null=True,
|
||||
help_text=_(
|
||||
"assign these custom fields, with optional values",
|
||||
),
|
||||
)
|
||||
|
||||
remove_tags = models.ManyToManyField(
|
||||
|
@@ -2017,7 +2017,7 @@ class WorkflowActionSerializer(serializers.ModelSerializer):
|
||||
"assign_view_groups",
|
||||
"assign_change_users",
|
||||
"assign_change_groups",
|
||||
"assign_custom_fields",
|
||||
"assign_custom_fields_w_values",
|
||||
"remove_all_tags",
|
||||
"remove_tags",
|
||||
"remove_all_correspondents",
|
||||
@@ -2135,7 +2135,6 @@ class WorkflowSerializer(serializers.ModelSerializer):
|
||||
assign_view_groups = action.pop("assign_view_groups", None)
|
||||
assign_change_users = action.pop("assign_change_users", None)
|
||||
assign_change_groups = action.pop("assign_change_groups", None)
|
||||
assign_custom_fields = action.pop("assign_custom_fields", None)
|
||||
remove_tags = action.pop("remove_tags", None)
|
||||
remove_correspondents = action.pop("remove_correspondents", None)
|
||||
remove_document_types = action.pop("remove_document_types", None)
|
||||
@@ -2185,8 +2184,6 @@ class WorkflowSerializer(serializers.ModelSerializer):
|
||||
action_instance.assign_change_users.set(assign_change_users)
|
||||
if assign_change_groups is not None:
|
||||
action_instance.assign_change_groups.set(assign_change_groups)
|
||||
if assign_custom_fields is not None:
|
||||
action_instance.assign_custom_fields.set(assign_custom_fields)
|
||||
if remove_tags is not None:
|
||||
action_instance.remove_tags.set(remove_tags)
|
||||
if remove_correspondents is not None:
|
||||
|
@@ -576,6 +576,8 @@ def cleanup_custom_field_deletion(sender, instance: CustomField, **kwargs):
|
||||
f"Removing custom field {instance} from sort field of {views_with_sort_updated} views",
|
||||
)
|
||||
|
||||
# Remove from workflow actions
|
||||
|
||||
|
||||
def add_to_index(sender, document, **kwargs):
|
||||
from documents import index
|
||||
|
Reference in New Issue
Block a user