A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
Fix: ignore nested action IDs on WF create (#14084)
shamoon26094bc8630b
diff --git a/src/documents/serialisers.py b/src/documents/serialisers.pyindex 744e658a0..791696f81 100644--- a/src/documents/serialisers.py+++ b/src/documents/serialisers.py@@ -3604,6 +3604,8 @@ class WorkflowSerializer(serializers.ModelSerializer[Workflow]):if "actions" in validated_data:actions = validated_data.pop("actions")+ for action in actions:+ action.pop("id", None)instance = super().create(validated_data)diff --git a/src/documents/tests/test_api_workflows.py b/src/documents/tests/test_api_workflows.pyindex 78563de3f..7c1b9b6c5 100644--- a/src/documents/tests/test_api_workflows.py+++ b/src/documents/tests/test_api_workflows.py@@ -194,6 +194,48 @@ class TestApiWorkflows(DirectoriesMixin, APITestCase):self.assertEqual(response.status_code, status.HTTP_201_CREATED)self.assertEqual(Workflow.objects.count(), 2)+ def test_api_create_workflow_ignores_nested_action_id(self) -> None:+ """+ GIVEN:+ - An existing workflow action+ WHEN:+ - API request to create a workflow includes that action's ID+ THEN:+ - A new action is created without changing the existing action+ """+ original_title = self.action.assign_title++ response = self.client.post(+ self.ENDPOINT,+ json.dumps(+ {+ "name": "Workflow 2",+ "order": 1,+ "triggers": [+ {+ "sources": [DocumentSource.ApiUpload],+ "type": WorkflowTrigger.WorkflowTriggerType.CONSUMPTION,+ "filter_filename": "*",+ },+ ],+ "actions": [+ {+ "id": self.action.id,+ "assign_title": "New Action Title",+ },+ ],+ },+ ),+ content_type="application/json",+ )++ self.assertEqual(response.status_code, status.HTTP_201_CREATED)+ self.action.refresh_from_db()+ self.assertEqual(self.action.assign_title, original_title)+ new_action = Workflow.objects.get(name="Workflow 2").actions.get()+ self.assertNotEqual(new_action.id, self.action.id)+ self.assertEqual(new_action.assign_title, "New Action Title")+def test_api_create_workflow_nested(self) -> None:"""GIVEN: