mirror of
https://github.com/sartography/spiffworkflow-backend.git
synced 2025-02-23 21:08:18 +00:00
allow marking task complete without executing
This commit is contained in:
parent
b08496f4b7
commit
71a154db1e
@ -861,33 +861,6 @@ paths:
|
||||
schema:
|
||||
$ref: "#/components/schemas/OkTrue"
|
||||
|
||||
/send-event/{modified_process_model_identifier}/{process_instance_id}:
|
||||
parameters:
|
||||
- name: modified_process_model_identifier
|
||||
in: path
|
||||
required: true
|
||||
description: The modified id of an existing process model
|
||||
schema:
|
||||
type: string
|
||||
- name: process_instance_id
|
||||
in: path
|
||||
required: true
|
||||
description: The unique id of the process instance
|
||||
schema:
|
||||
type: string
|
||||
post:
|
||||
operationId: spiffworkflow_backend.routes.process_api_blueprint.send_bpmn_event
|
||||
summary: Send a BPMN event to the process
|
||||
tags:
|
||||
- Process Instances
|
||||
responses:
|
||||
"200":
|
||||
description: Event Sent Successfully
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/Workflow"
|
||||
|
||||
/process-instances/reports:
|
||||
parameters:
|
||||
- name: page
|
||||
@ -1279,6 +1252,66 @@ paths:
|
||||
schema:
|
||||
$ref: "#/components/schemas/Workflow"
|
||||
|
||||
/send-event/{modified_process_model_identifier}/{process_instance_id}:
|
||||
parameters:
|
||||
- name: modified_process_model_identifier
|
||||
in: path
|
||||
required: true
|
||||
description: The modified id of an existing process model
|
||||
schema:
|
||||
type: string
|
||||
- name: process_instance_id
|
||||
in: path
|
||||
required: true
|
||||
description: The unique id of the process instance
|
||||
schema:
|
||||
type: string
|
||||
post:
|
||||
operationId: spiffworkflow_backend.routes.process_api_blueprint.send_bpmn_event
|
||||
summary: Send a BPMN event to the process
|
||||
tags:
|
||||
- Process Instances
|
||||
responses:
|
||||
"200":
|
||||
description: Event Sent Successfully
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/Workflow"
|
||||
|
||||
/task-complete/{modified_process_model_identifier}/{process_instance_id}/{task_id}:
|
||||
parameters:
|
||||
- name: modified_process_model_identifier
|
||||
in: path
|
||||
required: true
|
||||
description: The modified id of an existing process model
|
||||
schema:
|
||||
type: string
|
||||
- name: process_instance_id
|
||||
in: path
|
||||
required: true
|
||||
description: The unique id of the process instance
|
||||
schema:
|
||||
type: string
|
||||
- name: task_id
|
||||
in: path
|
||||
required: true
|
||||
description: The unique id of the task.
|
||||
schema:
|
||||
type: string
|
||||
post:
|
||||
operationId: spiffworkflow_backend.routes.process_api_blueprint.mark_task_complete
|
||||
summary: Mark a task complete without executing it
|
||||
tags:
|
||||
- Process Instances
|
||||
responses:
|
||||
"200":
|
||||
description: Event Sent Successfully
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/Workflow"
|
||||
|
||||
/service-tasks:
|
||||
get:
|
||||
tags:
|
||||
|
@ -2170,6 +2170,30 @@ def send_bpmn_event(
|
||||
)
|
||||
|
||||
|
||||
def mark_task_complete(
|
||||
modified_process_model_identifier: str,
|
||||
process_instance_id: str,
|
||||
task_id: str,
|
||||
body: Dict,
|
||||
) -> Response:
|
||||
process_instance = ProcessInstanceModel.query.filter(
|
||||
ProcessInstanceModel.id == int(process_instance_id)
|
||||
).first()
|
||||
if process_instance:
|
||||
processor = ProcessInstanceProcessor(process_instance)
|
||||
processor.mark_task_complete(task_id)
|
||||
else:
|
||||
raise ApiError(
|
||||
error_code="send_bpmn_event_error",
|
||||
message=f"Could not skip Task {task_id} in Instance {process_instance_id}",
|
||||
)
|
||||
return Response(
|
||||
json.dumps(ProcessInstanceModelSchema().dump(process_instance)),
|
||||
status=200,
|
||||
mimetype="application/json",
|
||||
)
|
||||
|
||||
|
||||
def commit_and_push_to_git(message: str) -> None:
|
||||
"""Commit_and_push_to_git."""
|
||||
if current_app.config["GIT_COMMIT_ON_SAVE"]:
|
||||
|
@ -17,6 +17,7 @@ from typing import Optional
|
||||
from typing import Tuple
|
||||
from typing import TypedDict
|
||||
from typing import Union
|
||||
from uuid import UUID
|
||||
|
||||
import dateparser
|
||||
import pytz
|
||||
@ -706,6 +707,8 @@ class ProcessInstanceProcessor:
|
||||
db.session.commit()
|
||||
|
||||
def serialize_task_spec(self, task_spec: SpiffTask) -> Any:
|
||||
# The task spec is NOT actually a SpiffTask, it is the task spec attached to a SpiffTask
|
||||
# Not sure why mypy accepts this but whatever.
|
||||
return self._serializer.spec_converter.convert(task_spec)
|
||||
|
||||
def send_bpmn_event(self, event_data: dict[str, Any]) -> None:
|
||||
@ -719,6 +722,17 @@ class ProcessInstanceProcessor:
|
||||
self.bpmn_process_instance.catch(event_definition)
|
||||
self.do_engine_steps(save=True)
|
||||
|
||||
def mark_task_complete(self, task_id: str) -> None:
|
||||
spiff_task = self.bpmn_process_instance.get_task(UUID(task_id))
|
||||
spiff_task._set_state(TaskState.COMPLETED)
|
||||
self.bpmn_process_instance.last_task = spiff_task
|
||||
for child in spiff_task.children:
|
||||
child.task_spec._update(child)
|
||||
current_app.logger.info(
|
||||
f"Task {spiff_task.task_spec.name} of process instance {self.process_instance_model.id} skipped"
|
||||
)
|
||||
self.do_engine_steps(save=True)
|
||||
|
||||
@staticmethod
|
||||
def get_parser() -> MyCustomParser:
|
||||
"""Get_parser."""
|
||||
|
Loading…
x
Reference in New Issue
Block a user