From 9bb3d98594dfcee4602e2d0aa52005289d7c4207 Mon Sep 17 00:00:00 2001 From: burnettk Date: Mon, 19 Dec 2022 23:08:54 -0500 Subject: [PATCH] fix filtering issue on completed instances tab and lint junk --- .../models/human_task.py | 2 +- .../models/human_task_user.py | 2 +- .../routes/process_api_blueprint.py | 24 +++++++++++-------- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/models/human_task.py b/spiffworkflow-backend/src/spiffworkflow_backend/models/human_task.py index 73936e49..26b99f39 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/models/human_task.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/models/human_task.py @@ -1,4 +1,4 @@ -"""human_task.""" +"""Human_task.""" from __future__ import annotations from dataclasses import dataclass diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/models/human_task_user.py b/spiffworkflow-backend/src/spiffworkflow_backend/models/human_task_user.py index 9113ee8e..7d98880f 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/models/human_task_user.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/models/human_task_user.py @@ -1,4 +1,4 @@ -"""human_task_user.""" +"""Human_task_user.""" from __future__ import annotations from dataclasses import dataclass diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_api_blueprint.py b/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_api_blueprint.py index 8b8d7168..f01635b0 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_api_blueprint.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_api_blueprint.py @@ -983,6 +983,14 @@ def process_instance_list( ProcessInstanceModel.status.in_(report_filter.process_status) # type: ignore ) + if report_filter.initiated_by_me is True: + process_instance_query = process_instance_query.filter( + ProcessInstanceModel.status.in_(ProcessInstanceModel.terminal_statuses()) # type: ignore + ) + process_instance_query = process_instance_query.filter_by( + process_initiator=g.user + ) + if report_filter.with_relation_to_me is True: process_instance_query = process_instance_query.outerjoin( HumanTaskModel @@ -1000,14 +1008,6 @@ def process_instance_list( ) ) - if report_filter.initiated_by_me is True: - process_instance_query = process_instance_query.filter( - ProcessInstanceModel.status.in_(ProcessInstanceModel.terminal_statuses()) # type: ignore - ) - process_instance_query = process_instance_query.filter_by( - process_initiator=g.user - ) - # TODO: not sure if this is exactly what is wanted if report_filter.with_tasks_completed_by_me is True: process_instance_query = process_instance_query.filter( @@ -1578,6 +1578,7 @@ def process_instance_task_list_without_task_data_for_me( all_tasks: bool = False, spiff_step: int = 0, ) -> flask.wrappers.Response: + """Process_instance_task_list_without_task_data_for_me.""" process_instance = _find_process_instance_for_me_or_raise(process_instance_id) print(f"process_instance: {process_instance}") return process_instance_task_list( @@ -2291,8 +2292,11 @@ def commit_and_push_to_git(message: str) -> None: 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 = ( +def _find_process_instance_for_me_or_raise( + process_instance_id: int, +) -> ProcessInstanceModel: + """_find_process_instance_for_me_or_raise.""" + process_instance: ProcessInstanceModel = ( ProcessInstanceModel.query.filter_by(id=process_instance_id) .outerjoin(HumanTaskModel) .outerjoin(