if lane owner name is an actual group, assume that we want tasks assigned to group
This commit is contained in:
parent
78c5ca1251
commit
0848c64299
|
@ -771,29 +771,31 @@ class ProcessInstanceProcessor:
|
|||
lane_assignment_id = None
|
||||
if re.match(r"(process.?)initiator", task_lane, re.IGNORECASE):
|
||||
potential_owner_ids = [self.process_instance_model.process_initiator_id]
|
||||
elif "lane_owners" in task.data and task_lane in task.data["lane_owners"]:
|
||||
for username in task.data["lane_owners"][task_lane]:
|
||||
lane_owner_user = UserModel.query.filter_by(username=username).first()
|
||||
if lane_owner_user is not None:
|
||||
potential_owner_ids.append(lane_owner_user.id)
|
||||
self.raise_if_no_potential_owners(
|
||||
potential_owner_ids,
|
||||
(
|
||||
"No users found in task data lane owner list for lane:"
|
||||
f" {task_lane}. The user list used:"
|
||||
f" {task.data['lane_owners'][task_lane]}"
|
||||
),
|
||||
)
|
||||
else:
|
||||
group_model = GroupModel.query.filter_by(identifier=task_lane).first()
|
||||
if group_model is None:
|
||||
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]
|
||||
lane_assignment_id = group_model.id
|
||||
self.raise_if_no_potential_owners(
|
||||
potential_owner_ids,
|
||||
f"Could not find any users in group to assign to lane: {task_lane}",
|
||||
)
|
||||
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]:
|
||||
lane_owner_user = UserModel.query.filter_by(username=username).first()
|
||||
if lane_owner_user is not None:
|
||||
potential_owner_ids.append(lane_owner_user.id)
|
||||
self.raise_if_no_potential_owners(
|
||||
potential_owner_ids,
|
||||
(
|
||||
"No users found in task data lane owner list for lane:"
|
||||
f" {task_lane}. The user list used:"
|
||||
f" {task.data['lane_owners'][task_lane]}"
|
||||
),
|
||||
)
|
||||
else:
|
||||
if group_model is None:
|
||||
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,
|
||||
f"Could not find any users in group to assign to lane: {task_lane}",
|
||||
)
|
||||
|
||||
return {
|
||||
"potential_owner_ids": potential_owner_ids,
|
||||
|
|
|
@ -164,7 +164,7 @@ class TestProcessInstanceProcessor(BaseTest):
|
|||
|
||||
assert len(process_instance.active_human_tasks) == 1
|
||||
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 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 len(process_instance.active_human_tasks) == 1
|
||||
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 human_task.potential_owners[0] == finance_user_four
|
||||
|
||||
|
|
Loading…
Reference in New Issue