From 9d4e096a5ddfcf07a8d9c77246745629cf988f34 Mon Sep 17 00:00:00 2001 From: jasquat Date: Tue, 8 Nov 2022 12:36:11 -0500 Subject: [PATCH] return next task when running an instance w/ burnettk --- .../services/process_instance_service.py | 15 +++++++++++++++ .../integration/test_process_api.py | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_service.py b/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_service.py index 062d0ef7c..5245313ac 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_service.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_service.py @@ -7,6 +7,7 @@ from typing import Optional from flask import current_app from flask_bpmn.api.api_error import ApiError from flask_bpmn.models.db import db +from SpiffWorkflow.util.deep_merge import DeepMerge # type: ignore from SpiffWorkflow.task import Task as SpiffTask # type: ignore from spiffworkflow_backend.models.process_instance import ProcessInstanceApi @@ -105,6 +106,20 @@ class ProcessInstanceService: title=title_value, ) + next_task_trying_again = next_task + if ( + not next_task + ): # The Next Task can be requested to be a certain task, useful for parallel tasks. + # This may or may not work, sometimes there is no next task to complete. + next_task_trying_again = processor.next_task() + + if next_task_trying_again is not None: + process_instance_api.next_task = ( + ProcessInstanceService.spiff_task_to_api_task( + next_task_trying_again, add_docs_and_forms=True + ) + ) + return process_instance_api def get_process_instance(self, process_instance_id: int) -> Any: diff --git a/spiffworkflow-backend/tests/spiffworkflow_backend/integration/test_process_api.py b/spiffworkflow-backend/tests/spiffworkflow_backend/integration/test_process_api.py index 394db2615..0de61b126 100644 --- a/spiffworkflow-backend/tests/spiffworkflow_backend/integration/test_process_api.py +++ b/spiffworkflow-backend/tests/spiffworkflow_backend/integration/test_process_api.py @@ -1123,7 +1123,7 @@ class TestProcessApi(BaseTest): ) assert response.json is not None - # assert response.json['next_task'] is not None + assert response.json['next_task'] is not None active_tasks = ( db.session.query(ActiveTaskModel)