mirror of
https://github.com/sartography/cr-connect-workflow.git
synced 2025-02-20 11:48:16 +00:00
I had to give up and live with the idea that we can only render documentation on the current task, not on the previous or next tasks. I think this is ok. If you want to view a task, you need to make it the active task to assure all the parts and pieces are in place.
This commit is contained in:
parent
8ded625c7d
commit
1571986c0e
@ -103,7 +103,7 @@ def __get_workflow_api_model(processor: WorkflowProcessor):
|
||||
)
|
||||
next_task = processor.next_task()
|
||||
if next_task:
|
||||
workflow_api.next_task = WorkflowService.spiff_task_to_api_task(next_task)
|
||||
workflow_api.next_task = WorkflowService.spiff_task_to_api_task(next_task, add_docs_and_forms=True)
|
||||
|
||||
return workflow_api
|
||||
|
||||
|
@ -62,7 +62,7 @@ class WorkflowService(object):
|
||||
we.sender)
|
||||
|
||||
@staticmethod
|
||||
def spiff_task_to_api_task(spiff_task):
|
||||
def spiff_task_to_api_task(spiff_task, add_docs_and_forms=False):
|
||||
task_type = spiff_task.task_spec.__class__.__name__
|
||||
|
||||
if isinstance(spiff_task.task_spec, UserTask):
|
||||
@ -109,8 +109,10 @@ class WorkflowService(object):
|
||||
process_name=spiff_task.task_spec._wf_spec.description,
|
||||
properties=props)
|
||||
|
||||
# Only process the form and documentation if this is something that is ready or completed.
|
||||
if not (spiff_task._is_predicted()):
|
||||
# Only process the form and documentation if requested.
|
||||
# The task should be in a completed or a ready state, and should
|
||||
# not be a previously completed MI Task.
|
||||
if add_docs_and_forms:
|
||||
if hasattr(spiff_task.task_spec, "form"):
|
||||
task.form = spiff_task.task_spec.form
|
||||
for field in task.form.fields:
|
||||
|
@ -49,18 +49,18 @@
|
||||
<dc:Bounds x="129" y="142" width="64" height="14" />
|
||||
</bpmndi:BPMNLabel>
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="ScriptTask_0cbbirp_di" bpmnElement="Task_1v0e2zu">
|
||||
<dc:Bounds x="250" y="77" width="100" height="80" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="Activity_1iyilui_di" bpmnElement="MutiInstanceTask">
|
||||
<dc:Bounds x="410" y="77" width="100" height="80" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="Event_1g0pmib_di" bpmnElement="Event_End">
|
||||
<dc:Bounds x="582" y="99" width="36" height="36" />
|
||||
<bpmndi:BPMNLabel>
|
||||
<dc:Bounds x="575" y="142" width="54" height="14" />
|
||||
</bpmndi:BPMNLabel>
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="Activity_1iyilui_di" bpmnElement="MutiInstanceTask">
|
||||
<dc:Bounds x="410" y="77" width="100" height="80" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="ScriptTask_0cbbirp_di" bpmnElement="Task_1v0e2zu">
|
||||
<dc:Bounds x="250" y="77" width="100" height="80" />
|
||||
</bpmndi:BPMNShape>
|
||||
</bpmndi:BPMNPlane>
|
||||
</bpmndi:BPMNDiagram>
|
||||
</bpmn:definitions>
|
||||
|
@ -79,10 +79,11 @@ class TestTasksApi(BaseTest):
|
||||
def test_get_current_user_tasks(self):
|
||||
self.load_example_data()
|
||||
workflow = self.create_workflow('random_fact')
|
||||
tasks = self.get_workflow_api(workflow).user_tasks
|
||||
self.assertEqual("Task_User_Select_Type", tasks[0].name)
|
||||
self.assertEqual(3, len(tasks[0].form["fields"][0]["options"]))
|
||||
self.assertIsNotNone(tasks[0].documentation)
|
||||
workflow = self.get_workflow_api(workflow)
|
||||
task = workflow.next_task
|
||||
self.assertEqual("Task_User_Select_Type", task['name'])
|
||||
self.assertEqual(3, len(task['form']["fields"][0]["options"]))
|
||||
self.assertIsNotNone(task['documentation'])
|
||||
expected_docs = """# h1 Heading 8-)
|
||||
## h2 Heading
|
||||
### h3 Heading
|
||||
@ -90,7 +91,7 @@ class TestTasksApi(BaseTest):
|
||||
##### h5 Heading
|
||||
###### h6 Heading
|
||||
"""
|
||||
self.assertTrue(str.startswith(tasks[0].documentation, expected_docs))
|
||||
self.assertTrue(str.startswith(task['documentation'], expected_docs))
|
||||
|
||||
def test_two_forms_task(self):
|
||||
# Set up a new workflow
|
||||
@ -100,7 +101,7 @@ class TestTasksApi(BaseTest):
|
||||
workflow_api = self.get_workflow_api(workflow)
|
||||
self.assertEqual('two_forms', workflow_api.workflow_spec_id)
|
||||
self.assertEqual(2, len(workflow_api.user_tasks))
|
||||
self.assertIsNotNone(workflow_api.user_tasks[0].form)
|
||||
self.assertIsNotNone(workflow_api.next_task['form'])
|
||||
self.assertEqual("UserTask", workflow_api.next_task['type'])
|
||||
self.assertEqual("StepOne", workflow_api.next_task['name'])
|
||||
self.assertEqual(1, len(workflow_api.next_task['form']['fields']))
|
||||
@ -194,10 +195,10 @@ class TestTasksApi(BaseTest):
|
||||
self.load_example_data()
|
||||
workflow = self.create_workflow('random_fact')
|
||||
workflow_api = self.get_workflow_api(workflow)
|
||||
tasks = workflow_api.user_tasks
|
||||
self.assertEqual("Task_User_Select_Type", tasks[0].name)
|
||||
self.assertEqual(3, len(tasks[0].form["fields"][0]["options"]))
|
||||
self.assertIsNotNone(tasks[0].documentation)
|
||||
task = workflow_api.next_task
|
||||
self.assertEqual("Task_User_Select_Type", task['name'])
|
||||
self.assertEqual(3, len(task['form']["fields"][0]["options"]))
|
||||
self.assertIsNotNone(task['documentation'])
|
||||
self.complete_form(workflow, workflow_api.user_tasks[0], {"type": "norris"})
|
||||
workflow_api = self.get_workflow_api(workflow)
|
||||
self.assertEqual("EndEvent_0u1cgrf", workflow_api.next_task['name'])
|
||||
@ -303,11 +304,11 @@ class TestTasksApi(BaseTest):
|
||||
self.load_example_data()
|
||||
workflow = self.create_workflow('enum_options_with_search')
|
||||
# get the first form in the two form workflow.
|
||||
tasks = self.get_workflow_api(workflow).user_tasks
|
||||
task = tasks[0]
|
||||
field_id = task.form['fields'][0]['id']
|
||||
workflow = self.get_workflow_api(workflow)
|
||||
task = workflow.next_task
|
||||
field_id = task['form']['fields'][0]['id']
|
||||
rv = self.app.get('/v1.0/workflow/%i/task/%s/lookup/%s?query=%s&limit=5' %
|
||||
(workflow.id, task.id, field_id, 'c'), # All records with a word that starts with 'c'
|
||||
(workflow.id, task['id'], field_id, 'c'), # All records with a word that starts with 'c'
|
||||
headers=self.logged_in_headers(),
|
||||
content_type="application/json")
|
||||
self.assert_success(rv)
|
||||
@ -395,13 +396,13 @@ class TestTasksApi(BaseTest):
|
||||
self.assertEquals("MutiInstanceTask", tasks[0].name)
|
||||
self.assertEquals("Gather more information", tasks[0].title)
|
||||
|
||||
self.complete_form(workflow, tasks[0], {"email": "dhf8r@virginia.edu"})
|
||||
self.complete_form(workflow, tasks[0], {"investigator":{"email": "dhf8r@virginia.edu"}})
|
||||
tasks = self.get_workflow_api(workflow).user_tasks
|
||||
|
||||
self.complete_form(workflow, tasks[2], {"email": "abc@virginia.edu"})
|
||||
self.complete_form(workflow, tasks[2], {"investigator":{"email": "abc@virginia.edu"}})
|
||||
tasks = self.get_workflow_api(workflow).user_tasks
|
||||
|
||||
self.complete_form(workflow, tasks[1], {"email": "def@virginia.edu"})
|
||||
self.complete_form(workflow, tasks[1], {"investigator":{"email": "def@virginia.edu"}})
|
||||
tasks = self.get_workflow_api(workflow).user_tasks
|
||||
|
||||
workflow = self.get_workflow_api(workflow)
|
||||
|
Loading…
x
Reference in New Issue
Block a user