From 07f3d2c2ee64526bef04eed96be7adbf794f22ad Mon Sep 17 00:00:00 2001 From: mike cullerton Date: Fri, 7 May 2021 14:06:53 -0400 Subject: [PATCH 1/2] Allow data from read-only fields to persist in task_data --- crc/services/workflow_service.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/crc/services/workflow_service.py b/crc/services/workflow_service.py index 101929d4..a76553ce 100644 --- a/crc/services/workflow_service.py +++ b/crc/services/workflow_service.py @@ -739,10 +739,7 @@ class WorkflowService(object): if hasattr(task.task_spec, 'form'): for field in task.task_spec.form.fields: - if field.has_property(Task.FIELD_PROP_READ_ONLY) and \ - field.get_property(Task.FIELD_PROP_READ_ONLY).lower().strip() == "true": - continue # Don't add read-only data - elif field.has_property(Task.FIELD_PROP_REPEAT): + if field.has_property(Task.FIELD_PROP_REPEAT): group = field.get_property(Task.FIELD_PROP_REPEAT) if group in latest_data: data[group] = latest_data[group] From 67321ecd977869fafbe9894f31f697e057cd0f44 Mon Sep 17 00:00:00 2001 From: mike cullerton Date: Fri, 7 May 2021 14:07:19 -0400 Subject: [PATCH 2/2] Test and workflow for persisting read-only data --- .../data/read_only_field/read_only_field.bpmn | 77 +++++++++++++++++++ .../workflow/test_workflow_read_only_field.py | 16 ++++ 2 files changed, 93 insertions(+) create mode 100644 tests/data/read_only_field/read_only_field.bpmn create mode 100644 tests/workflow/test_workflow_read_only_field.py diff --git a/tests/data/read_only_field/read_only_field.bpmn b/tests/data/read_only_field/read_only_field.bpmn new file mode 100644 index 00000000..3620afdf --- /dev/null +++ b/tests/data/read_only_field/read_only_field.bpmn @@ -0,0 +1,77 @@ + + + + + Flow_0to8etb + + + + + + Flow_0a95kns + + + + Flow_0to8etb + Flow_04r75ca + string_value = 'asdf' + + + + + + + + + + + + + Flow_04r75ca + Flow_0g25v76 + + + Read only is {{ read_only_field }} + Flow_0g25v76 + Flow_0a95kns + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/workflow/test_workflow_read_only_field.py b/tests/workflow/test_workflow_read_only_field.py new file mode 100644 index 00000000..804650d8 --- /dev/null +++ b/tests/workflow/test_workflow_read_only_field.py @@ -0,0 +1,16 @@ +from tests.base_test import BaseTest + + +class TestReadOnlyField(BaseTest): + + def test_read_only(self): + + workflow = self.create_workflow('read_only_field') + workflow_api = self.get_workflow_api(workflow) + first_task = workflow_api.next_task + read_only_field = first_task.data['read_only_field'] + self.complete_form(workflow, first_task, {'read_only_field': read_only_field}) + workflow_api = self.get_workflow_api(workflow) + task = workflow_api.next_task + + self.assertEqual('Read only is asdf', task.documentation) \ No newline at end of file