From d15289ffc218c2d669acfdf35d909f4f1ce1846c Mon Sep 17 00:00:00 2001 From: jasquat <2487833+jasquat@users.noreply.github.com> Date: Wed, 14 Jun 2023 12:11:20 -0400 Subject: [PATCH] Feature/exclude user from group assignment (#332) * check if user in group also has the task assigned to them when returning process instances w/ burnettk * only check if user is assigned task if querying for active tasks w/ burnettk --------- Co-authored-by: jasquat --- .../config/permissions/local_development.yml | 2 +- .../services/process_instance_processor.py | 4 +++- .../services/process_instance_report_service.py | 11 +++++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/config/permissions/local_development.yml b/spiffworkflow-backend/src/spiffworkflow_backend/config/permissions/local_development.yml index 4b596568..9ea0c22e 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/config/permissions/local_development.yml +++ b/spiffworkflow-backend/src/spiffworkflow_backend/config/permissions/local_development.yml @@ -3,7 +3,7 @@ groups: admin: users: [admin@spiffworkflow.org] group1: - users: [jason@sartography.com, kb@sartography.com] + users: [jason@sartography.com, kevin@sartography.com] group2: users: [dan@sartography.com] diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_processor.py b/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_processor.py index c3c95c3a..17ef2877 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_processor.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_processor.py @@ -790,7 +790,9 @@ class ProcessInstanceProcessor: ) else: if group_model is None: - raise (NoPotentialOwnersForTaskError(f"Could not find a group with name matching lane: {task_lane}")) + raise ( + NoPotentialOwnersForTaskError(f"Could not find a group with name matching lane: {task_lane}") + ) potential_owner_ids = [i.user_id for i in group_model.user_group_assignments] self.raise_if_no_potential_owners( potential_owner_ids, diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_report_service.py b/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_report_service.py index c9f1ebb7..56b6fdb4 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_report_service.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_report_service.py @@ -500,6 +500,17 @@ class ProcessInstanceReportService: HumanTaskModel.completed.is_(False) # type: ignore ) + # Check to make sure the task is not only available for the group but the user as well + if instances_with_tasks_waiting_for_me is not True: + human_task_user_alias = aliased(HumanTaskUserModel) + process_instance_query = process_instance_query.join( + human_task_user_alias, + and_( + human_task_user_alias.human_task_id == HumanTaskModel.id, + human_task_user_alias.user_id == user.id, + ), + ) + process_instance_query = process_instance_query.join(GroupModel, and_(*group_model_join_conditions)) process_instance_query = process_instance_query.join( UserGroupAssignmentModel,