fix getting task info for a process instance w/ burnettk
This commit is contained in:
parent
62231ec7fc
commit
5fa6be6651
|
@ -798,6 +798,53 @@ paths:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/Workflow"
|
$ref: "#/components/schemas/Workflow"
|
||||||
|
|
||||||
|
/process-instances/for-me/{modified_process_model_identifier}/{process_instance_id}/task-info:
|
||||||
|
parameters:
|
||||||
|
- name: modified_process_model_identifier
|
||||||
|
in: path
|
||||||
|
required: true
|
||||||
|
description: The unique id of an existing process model
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
- name: process_instance_id
|
||||||
|
in: path
|
||||||
|
required: true
|
||||||
|
description: The unique id of an existing process instance.
|
||||||
|
schema:
|
||||||
|
type: integer
|
||||||
|
- name: process_identifier
|
||||||
|
in: query
|
||||||
|
required: false
|
||||||
|
description: The identifier of the process to use for the diagram. Useful for displaying the diagram for a call activity.
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
- name: all_tasks
|
||||||
|
in: query
|
||||||
|
required: false
|
||||||
|
description: If true, this wil return all tasks associated with the process instance and not just user tasks.
|
||||||
|
schema:
|
||||||
|
type: boolean
|
||||||
|
- name: spiff_step
|
||||||
|
in: query
|
||||||
|
required: false
|
||||||
|
description: If set will return the tasks as they were during a specific step of execution.
|
||||||
|
schema:
|
||||||
|
type: integer
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- Process Instances
|
||||||
|
operationId: spiffworkflow_backend.routes.process_api_blueprint.process_instance_task_list_without_task_data_for_me
|
||||||
|
summary: returns the list of all user tasks associated with process instance without the task data
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: list of tasks
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: "#/components/schemas/Task"
|
||||||
|
|
||||||
/process-instances/{modified_process_model_identifier}/{process_instance_id}/task-info:
|
/process-instances/{modified_process_model_identifier}/{process_instance_id}/task-info:
|
||||||
parameters:
|
parameters:
|
||||||
- name: modified_process_model_identifier
|
- name: modified_process_model_identifier
|
||||||
|
|
|
@ -1180,34 +1180,7 @@ def process_instance_show_for_me(
|
||||||
process_identifier: Optional[str] = None,
|
process_identifier: Optional[str] = None,
|
||||||
) -> flask.wrappers.Response:
|
) -> flask.wrappers.Response:
|
||||||
"""Process_instance_show_for_me."""
|
"""Process_instance_show_for_me."""
|
||||||
process_instance = (
|
process_instance = _find_process_instance_for_me_or_raise(process_instance_id)
|
||||||
ProcessInstanceModel.query.filter_by(id=process_instance_id)
|
|
||||||
.outerjoin(HumanTaskModel)
|
|
||||||
.outerjoin(
|
|
||||||
HumanTaskUserModel,
|
|
||||||
and_(
|
|
||||||
HumanTaskModel.id == HumanTaskUserModel.human_task_id,
|
|
||||||
HumanTaskUserModel.user_id == g.user.id,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.filter(
|
|
||||||
or_(
|
|
||||||
HumanTaskUserModel.id.is_not(None),
|
|
||||||
ProcessInstanceModel.process_initiator_id == g.user.id,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.first()
|
|
||||||
)
|
|
||||||
|
|
||||||
if process_instance is None:
|
|
||||||
raise (
|
|
||||||
ApiError(
|
|
||||||
error_code="process_instance_cannot_be_found",
|
|
||||||
message=f"Process instance with id {process_instance_id} cannot be found that is associated with you.",
|
|
||||||
status_code=400,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
return _get_process_instance(
|
return _get_process_instance(
|
||||||
process_instance=process_instance,
|
process_instance=process_instance,
|
||||||
modified_process_model_identifier=modified_process_model_identifier,
|
modified_process_model_identifier=modified_process_model_identifier,
|
||||||
|
@ -1599,6 +1572,23 @@ def get_tasks(
|
||||||
return make_response(jsonify(response_json), 200)
|
return make_response(jsonify(response_json), 200)
|
||||||
|
|
||||||
|
|
||||||
|
def process_instance_task_list_without_task_data_for_me(
|
||||||
|
modified_process_model_identifier: str,
|
||||||
|
process_instance_id: int,
|
||||||
|
all_tasks: bool = False,
|
||||||
|
spiff_step: int = 0,
|
||||||
|
) -> flask.wrappers.Response:
|
||||||
|
process_instance = _find_process_instance_for_me_or_raise(process_instance_id)
|
||||||
|
print(f"process_instance: {process_instance}")
|
||||||
|
return process_instance_task_list(
|
||||||
|
modified_process_model_identifier,
|
||||||
|
process_instance,
|
||||||
|
all_tasks,
|
||||||
|
spiff_step,
|
||||||
|
get_task_data=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def process_instance_task_list_without_task_data(
|
def process_instance_task_list_without_task_data(
|
||||||
modified_process_model_identifier: str,
|
modified_process_model_identifier: str,
|
||||||
process_instance_id: int,
|
process_instance_id: int,
|
||||||
|
@ -1606,9 +1596,10 @@ def process_instance_task_list_without_task_data(
|
||||||
spiff_step: int = 0,
|
spiff_step: int = 0,
|
||||||
) -> flask.wrappers.Response:
|
) -> flask.wrappers.Response:
|
||||||
"""Process_instance_task_list_without_task_data."""
|
"""Process_instance_task_list_without_task_data."""
|
||||||
|
process_instance = find_process_instance_by_id_or_raise(process_instance_id)
|
||||||
return process_instance_task_list(
|
return process_instance_task_list(
|
||||||
modified_process_model_identifier,
|
modified_process_model_identifier,
|
||||||
process_instance_id,
|
process_instance,
|
||||||
all_tasks,
|
all_tasks,
|
||||||
spiff_step,
|
spiff_step,
|
||||||
get_task_data=False,
|
get_task_data=False,
|
||||||
|
@ -1622,9 +1613,10 @@ def process_instance_task_list_with_task_data(
|
||||||
spiff_step: int = 0,
|
spiff_step: int = 0,
|
||||||
) -> flask.wrappers.Response:
|
) -> flask.wrappers.Response:
|
||||||
"""Process_instance_task_list_with_task_data."""
|
"""Process_instance_task_list_with_task_data."""
|
||||||
|
process_instance = find_process_instance_by_id_or_raise(process_instance_id)
|
||||||
return process_instance_task_list(
|
return process_instance_task_list(
|
||||||
modified_process_model_identifier,
|
modified_process_model_identifier,
|
||||||
process_instance_id,
|
process_instance,
|
||||||
all_tasks,
|
all_tasks,
|
||||||
spiff_step,
|
spiff_step,
|
||||||
get_task_data=True,
|
get_task_data=True,
|
||||||
|
@ -1633,19 +1625,17 @@ def process_instance_task_list_with_task_data(
|
||||||
|
|
||||||
def process_instance_task_list(
|
def process_instance_task_list(
|
||||||
_modified_process_model_identifier: str,
|
_modified_process_model_identifier: str,
|
||||||
process_instance_id: int,
|
process_instance: ProcessInstanceModel,
|
||||||
all_tasks: bool = False,
|
all_tasks: bool = False,
|
||||||
spiff_step: int = 0,
|
spiff_step: int = 0,
|
||||||
get_task_data: bool = False,
|
get_task_data: bool = False,
|
||||||
) -> flask.wrappers.Response:
|
) -> flask.wrappers.Response:
|
||||||
"""Process_instance_task_list."""
|
"""Process_instance_task_list."""
|
||||||
process_instance = find_process_instance_by_id_or_raise(process_instance_id)
|
|
||||||
|
|
||||||
if spiff_step > 0:
|
if spiff_step > 0:
|
||||||
step_detail = (
|
step_detail = (
|
||||||
db.session.query(SpiffStepDetailsModel)
|
db.session.query(SpiffStepDetailsModel)
|
||||||
.filter(
|
.filter(
|
||||||
SpiffStepDetailsModel.process_instance_id == process_instance.id,
|
SpiffStepDetailsModel.process_instance.id == process_instance.id,
|
||||||
SpiffStepDetailsModel.spiff_step == spiff_step,
|
SpiffStepDetailsModel.spiff_step == spiff_step,
|
||||||
)
|
)
|
||||||
.first()
|
.first()
|
||||||
|
@ -2299,3 +2289,35 @@ def commit_and_push_to_git(message: str) -> None:
|
||||||
current_app.logger.info(f"git output: {git_output}")
|
current_app.logger.info(f"git output: {git_output}")
|
||||||
else:
|
else:
|
||||||
current_app.logger.info("Git commit on save is disabled")
|
current_app.logger.info("Git commit on save is disabled")
|
||||||
|
|
||||||
|
|
||||||
|
def _find_process_instance_for_me_or_raise(process_instance_id: int) -> ProcessInstanceModel:
|
||||||
|
process_instance = (
|
||||||
|
ProcessInstanceModel.query.filter_by(id=process_instance_id)
|
||||||
|
.outerjoin(HumanTaskModel)
|
||||||
|
.outerjoin(
|
||||||
|
HumanTaskUserModel,
|
||||||
|
and_(
|
||||||
|
HumanTaskModel.id == HumanTaskUserModel.human_task_id,
|
||||||
|
HumanTaskUserModel.user_id == g.user.id,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.filter(
|
||||||
|
or_(
|
||||||
|
HumanTaskUserModel.id.is_not(None),
|
||||||
|
ProcessInstanceModel.process_initiator_id == g.user.id,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.first()
|
||||||
|
)
|
||||||
|
|
||||||
|
if process_instance is None:
|
||||||
|
raise (
|
||||||
|
ApiError(
|
||||||
|
error_code="process_instance_cannot_be_found",
|
||||||
|
message=f"Process instance with id {process_instance_id} cannot be found that is associated with you.",
|
||||||
|
status_code=400,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
return process_instance
|
||||||
|
|
|
@ -18,6 +18,7 @@ export const useUriListForPermissions = () => {
|
||||||
processInstanceSuspendPath: `/v1.0/process-instance-suspend/${params.process_model_id}/${params.process_instance_id}`,
|
processInstanceSuspendPath: `/v1.0/process-instance-suspend/${params.process_model_id}/${params.process_instance_id}`,
|
||||||
processInstanceTaskListDataPath: `/v1.0/task-data/${params.process_model_id}/${params.process_instance_id}`,
|
processInstanceTaskListDataPath: `/v1.0/task-data/${params.process_model_id}/${params.process_instance_id}`,
|
||||||
processInstanceTaskListPath: `/v1.0/process-instances/${params.process_model_id}/${params.process_instance_id}/task-info`,
|
processInstanceTaskListPath: `/v1.0/process-instances/${params.process_model_id}/${params.process_instance_id}/task-info`,
|
||||||
|
processInstanceTaskListForMePath: `/v1.0/process-instances/for-me/${params.process_model_id}/${params.process_instance_id}/task-info`,
|
||||||
processInstanceTerminatePath: `/v1.0/process-instance-terminate/${params.process_model_id}/${params.process_instance_id}`,
|
processInstanceTerminatePath: `/v1.0/process-instance-terminate/${params.process_model_id}/${params.process_instance_id}`,
|
||||||
processModelCreatePath: `/v1.0/process-models/${params.process_group_id}`,
|
processModelCreatePath: `/v1.0/process-models/${params.process_group_id}`,
|
||||||
processModelFileCreatePath: `/v1.0/process-models/${params.process_model_id}/files`,
|
processModelFileCreatePath: `/v1.0/process-models/${params.process_model_id}/files`,
|
||||||
|
|
|
@ -72,9 +72,14 @@ export default function ProcessInstanceShow({ variant }: OwnProps) {
|
||||||
const modifiedProcessModelId = params.process_model_id;
|
const modifiedProcessModelId = params.process_model_id;
|
||||||
|
|
||||||
const { targetUris } = useUriListForPermissions();
|
const { targetUris } = useUriListForPermissions();
|
||||||
|
const taskListPath =
|
||||||
|
variant === 'all'
|
||||||
|
? targetUris.processInstanceTaskListPath
|
||||||
|
: targetUris.processInstanceTaskListForMePath;
|
||||||
|
|
||||||
const permissionRequestData: PermissionsToCheck = {
|
const permissionRequestData: PermissionsToCheck = {
|
||||||
[targetUris.messageInstanceListPath]: ['GET'],
|
[targetUris.messageInstanceListPath]: ['GET'],
|
||||||
[targetUris.processInstanceTaskListPath]: ['GET'],
|
[taskListPath]: ['GET'],
|
||||||
[targetUris.processInstanceTaskListDataPath]: ['GET', 'PUT'],
|
[targetUris.processInstanceTaskListDataPath]: ['GET', 'PUT'],
|
||||||
[targetUris.processInstanceActionPath]: ['DELETE'],
|
[targetUris.processInstanceActionPath]: ['DELETE'],
|
||||||
[targetUris.processInstanceLogListPath]: ['GET'],
|
[targetUris.processInstanceLogListPath]: ['GET'],
|
||||||
|
@ -118,8 +123,8 @@ export default function ProcessInstanceShow({ variant }: OwnProps) {
|
||||||
let taskPath = '';
|
let taskPath = '';
|
||||||
if (ability.can('GET', targetUris.processInstanceTaskListDataPath)) {
|
if (ability.can('GET', targetUris.processInstanceTaskListDataPath)) {
|
||||||
taskPath = `${targetUris.processInstanceTaskListDataPath}${taskParams}`;
|
taskPath = `${targetUris.processInstanceTaskListDataPath}${taskParams}`;
|
||||||
} else if (ability.can('GET', targetUris.processInstanceTaskListPath)) {
|
} else if (ability.can('GET', taskListPath)) {
|
||||||
taskPath = `${targetUris.processInstanceTaskListPath}${taskParams}`;
|
taskPath = `${taskListPath}${taskParams}`;
|
||||||
}
|
}
|
||||||
if (taskPath) {
|
if (taskPath) {
|
||||||
HttpService.makeCallToBackend({
|
HttpService.makeCallToBackend({
|
||||||
|
|
Loading…
Reference in New Issue