if lane owner name is an actual group, assume that we want tasks assigned to group

This commit is contained in:
burnettk 2023-06-13 21:59:17 -04:00
parent 78c5ca1251
commit 0848c64299
2 changed files with 25 additions and 23 deletions

View File

@ -771,7 +771,11 @@ class ProcessInstanceProcessor:
lane_assignment_id = None lane_assignment_id = None
if re.match(r"(process.?)initiator", task_lane, re.IGNORECASE): if re.match(r"(process.?)initiator", task_lane, re.IGNORECASE):
potential_owner_ids = [self.process_instance_model.process_initiator_id] potential_owner_ids = [self.process_instance_model.process_initiator_id]
elif "lane_owners" in task.data and task_lane in task.data["lane_owners"]: else:
group_model = GroupModel.query.filter_by(identifier=task_lane).first()
if group_model is not None:
lane_assignment_id = group_model.id
if "lane_owners" in task.data and task_lane in task.data["lane_owners"]:
for username in task.data["lane_owners"][task_lane]: for username in task.data["lane_owners"][task_lane]:
lane_owner_user = UserModel.query.filter_by(username=username).first() lane_owner_user = UserModel.query.filter_by(username=username).first()
if lane_owner_user is not None: if lane_owner_user is not None:
@ -785,11 +789,9 @@ class ProcessInstanceProcessor:
), ),
) )
else: else:
group_model = GroupModel.query.filter_by(identifier=task_lane).first()
if group_model is None: 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] potential_owner_ids = [i.user_id for i in group_model.user_group_assignments]
lane_assignment_id = group_model.id
self.raise_if_no_potential_owners( self.raise_if_no_potential_owners(
potential_owner_ids, potential_owner_ids,
f"Could not find any users in group to assign to lane: {task_lane}", f"Could not find any users in group to assign to lane: {task_lane}",

View File

@ -164,7 +164,7 @@ class TestProcessInstanceProcessor(BaseTest):
assert len(process_instance.active_human_tasks) == 1 assert len(process_instance.active_human_tasks) == 1
human_task = process_instance.active_human_tasks[0] human_task = process_instance.active_human_tasks[0]
assert human_task.lane_assignment_id is None assert human_task.lane_assignment_id == finance_group.id
assert len(human_task.potential_owners) == 2 assert len(human_task.potential_owners) == 2
assert human_task.potential_owners == [finance_user_three, finance_user_four] assert human_task.potential_owners == [finance_user_three, finance_user_four]
@ -179,7 +179,7 @@ class TestProcessInstanceProcessor(BaseTest):
assert human_task.completed_by_user_id == finance_user_three.id assert human_task.completed_by_user_id == finance_user_three.id
assert len(process_instance.active_human_tasks) == 1 assert len(process_instance.active_human_tasks) == 1
human_task = process_instance.active_human_tasks[0] human_task = process_instance.active_human_tasks[0]
assert human_task.lane_assignment_id is None assert human_task.lane_assignment_id == finance_group.id
assert len(human_task.potential_owners) == 1 assert len(human_task.potential_owners) == 1
assert human_task.potential_owners[0] == finance_user_four assert human_task.potential_owners[0] == finance_user_four