WIP: deleting user after approval w/ burnettk

This commit is contained in:
jasquat 2022-10-25 15:42:13 -04:00
parent 8659f2122e
commit 24a96ccdfa
3 changed files with 74 additions and 28 deletions

View File

@ -540,7 +540,11 @@ class ProcessInstanceProcessor:
self.raise_if_no_potential_owners(
potential_owner_ids,
f"No users found in task data lane owner list for lane: {task_lane}. "
<<<<<<< Updated upstream
f"The user list used: {task.data['lane_owners'][task_lane]}",
=======
f"The user list used: {task.data['lane_owners'][task_lane]}"
>>>>>>> Stashed changes
)
else:
group_model = GroupModel.query.filter_by(identifier=task_lane).first()
@ -554,10 +558,14 @@ class ProcessInstanceProcessor:
i.user_id for i in group_model.user_group_assignments
]
lane_assignment_id = group_model.id
<<<<<<< Updated upstream
self.raise_if_no_potential_owners(
potential_owner_ids,
f"Could not find any users in group to assign to lane: {task_lane}",
)
=======
self.raise_if_no_potential_owners(potential_owner_ids, f"Could not find any users in group to assign to lane: {task_lane}")
>>>>>>> Stashed changes
return {
"potential_owner_ids": potential_owner_ids,
@ -597,9 +605,14 @@ class ProcessInstanceProcessor:
# filter out non-usertasks
task_spec = ready_or_waiting_task.task_spec
if not self.bpmn_process_instance._is_engine_task(task_spec):
<<<<<<< Updated upstream
potential_owner_hash = self.get_potential_owner_ids_from_task(
ready_or_waiting_task
)
=======
print(f"ready_or_waiting_task.data['current_user']['id']: {ready_or_waiting_task.data['current_user']['id']}")
potential_owner_hash = self.get_potential_owner_ids_from_task(ready_or_waiting_task)
>>>>>>> Stashed changes
extensions = ready_or_waiting_task.task_spec.extensions
form_file_name = None

View File

@ -12,7 +12,8 @@
<bpmn:flowNodeRef>Activity_0wq6mdd</bpmn:flowNodeRef>
</bpmn:lane>
<bpmn:lane id="finance_team" name="Finance Team">
<bpmn:flowNodeRef>finance_approval</bpmn:flowNodeRef>
<bpmn:flowNodeRef>finance_approval_one</bpmn:flowNodeRef>
<bpmn:flowNodeRef>finance_approval_two</bpmn:flowNodeRef>
</bpmn:lane>
<bpmn:lane id="bigwig" name="Bigwig">
<bpmn:flowNodeRef>Event_0nsh6vv</bpmn:flowNodeRef>
@ -30,7 +31,6 @@
<bpmn:incoming>Flow_1tbyols</bpmn:incoming>
<bpmn:outgoing>Flow_0xyca1b</bpmn:outgoing>
</bpmn:manualTask>
<bpmn:sequenceFlow id="Flow_1cfcauf" sourceRef="finance_approval" targetRef="initiator_two" />
<bpmn:sequenceFlow id="Flow_0jh05kw" sourceRef="initiator_two" targetRef="bigwig_approval" />
<bpmn:sequenceFlow id="Flow_04sc2wb" sourceRef="bigwig_approval" targetRef="Event_0nsh6vv" />
<bpmn:sequenceFlow id="Flow_0xyca1b" sourceRef="initator_one" targetRef="Activity_0wq6mdd" />
@ -38,16 +38,9 @@
<bpmn:extensionElements>
<spiffworkflow:instructionsForEndUser>This is initiator again?</spiffworkflow:instructionsForEndUser>
</bpmn:extensionElements>
<bpmn:incoming>Flow_1cfcauf</bpmn:incoming>
<bpmn:incoming>Flow_1aluose</bpmn:incoming>
<bpmn:outgoing>Flow_0jh05kw</bpmn:outgoing>
</bpmn:manualTask>
<bpmn:manualTask id="finance_approval" name="Finance Approval">
<bpmn:extensionElements>
<spiffworkflow:instructionsForEndUser>This is finance user?</spiffworkflow:instructionsForEndUser>
</bpmn:extensionElements>
<bpmn:incoming>Flow_13ejjwk</bpmn:incoming>
<bpmn:outgoing>Flow_1cfcauf</bpmn:outgoing>
</bpmn:manualTask>
<bpmn:endEvent id="Event_0nsh6vv">
<bpmn:incoming>Flow_04sc2wb</bpmn:incoming>
</bpmn:endEvent>
@ -55,7 +48,7 @@
<bpmn:incoming>Flow_0jh05kw</bpmn:incoming>
<bpmn:outgoing>Flow_04sc2wb</bpmn:outgoing>
</bpmn:manualTask>
<bpmn:sequenceFlow id="Flow_13ejjwk" sourceRef="Activity_0wq6mdd" targetRef="finance_approval" />
<bpmn:sequenceFlow id="Flow_13ejjwk" sourceRef="Activity_0wq6mdd" targetRef="finance_approval_one" />
<bpmn:scriptTask id="Activity_0wq6mdd" name="Set Potential Owners For Lanes" scriptFormat="python">
<bpmn:incoming>Flow_0xyca1b</bpmn:incoming>
<bpmn:outgoing>Flow_13ejjwk</bpmn:outgoing>
@ -65,6 +58,22 @@
"Process Initiator": ['testadmin1']
}</bpmn:script>
</bpmn:scriptTask>
<bpmn:sequenceFlow id="Flow_1i3fkto" sourceRef="finance_approval_one" targetRef="finance_approval_two" />
<bpmn:sequenceFlow id="Flow_1aluose" sourceRef="finance_approval_two" targetRef="initiator_two" />
<bpmn:manualTask id="finance_approval_one" name="Finance Approval One">
<bpmn:extensionElements>
<spiffworkflow:instructionsForEndUser>This is finance user one?</spiffworkflow:instructionsForEndUser>
</bpmn:extensionElements>
<bpmn:incoming>Flow_13ejjwk</bpmn:incoming>
<bpmn:outgoing>Flow_1i3fkto</bpmn:outgoing>
</bpmn:manualTask>
<bpmn:manualTask id="finance_approval_two" name="Finance Approval Two">
<bpmn:extensionElements>
<spiffworkflow:instructionsForEndUser>This is finance user two?</spiffworkflow:instructionsForEndUser>
</bpmn:extensionElements>
<bpmn:incoming>Flow_1i3fkto</bpmn:incoming>
<bpmn:outgoing>Flow_1aluose</bpmn:outgoing>
</bpmn:manualTask>
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Collaboration_0iyw0q7">
@ -94,10 +103,6 @@
<dc:Bounds x="550" y="137" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_1y566d5_di" bpmnElement="finance_approval">
<dc:Bounds x="430" y="320" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_0nsh6vv_di" bpmnElement="Event_0nsh6vv">
<dc:Bounds x="672" y="-28" width="36" height="36" />
</bpmndi:BPMNShape>
@ -109,15 +114,17 @@
<dc:Bounds x="420" y="140" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_1y566d5_di" bpmnElement="finance_approval_one">
<dc:Bounds x="420" y="320" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_1rq1fsj_di" bpmnElement="finance_approval_two">
<dc:Bounds x="550" y="320" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="Flow_1tbyols_di" bpmnElement="Flow_1tbyols">
<di:waypoint x="215" y="177" />
<di:waypoint x="270" y="177" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1cfcauf_di" bpmnElement="Flow_1cfcauf">
<di:waypoint x="530" y="360" />
<di:waypoint x="600" y="360" />
<di:waypoint x="600" y="217" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0jh05kw_di" bpmnElement="Flow_0jh05kw">
<di:waypoint x="600" y="137" />
<di:waypoint x="600" y="30" />
@ -131,8 +138,16 @@
<di:waypoint x="420" y="180" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_13ejjwk_di" bpmnElement="Flow_13ejjwk">
<di:waypoint x="470" y="220" />
<di:waypoint x="470" y="320" />
<di:waypoint x="460" y="220" />
<di:waypoint x="460" y="320" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1i3fkto_di" bpmnElement="Flow_1i3fkto">
<di:waypoint x="520" y="360" />
<di:waypoint x="550" y="360" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1aluose_di" bpmnElement="Flow_1aluose">
<di:waypoint x="600" y="320" />
<di:waypoint x="600" y="217" />
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>

View File

@ -126,10 +126,11 @@ class TestProcessInstanceProcessor(BaseTest):
) -> None:
"""Test_sets_permission_correctly_on_active_task_when_using_dict."""
initiator_user = self.find_or_create_user("initiator_user")
finance_user = self.find_or_create_user("testuser3")
finance_user_three = self.find_or_create_user("testuser3")
finance_user_four = self.find_or_create_user("testuser4")
testadmin1 = self.find_or_create_user("testadmin1")
assert initiator_user.principal is not None
assert finance_user.principal is not None
assert finance_user_three.principal is not None
AuthorizationService.import_permissions_from_yaml_file()
finance_group = GroupModel.query.filter_by(identifier="Finance Team").first()
@ -156,7 +157,7 @@ class TestProcessInstanceProcessor(BaseTest):
)
with pytest.raises(UserDoesNotHaveAccessToTaskError):
ProcessInstanceService.complete_form_task(
processor, spiff_task, {}, finance_user
processor, spiff_task, {}, finance_user_three
)
ProcessInstanceService.complete_form_task(
processor, spiff_task, {}, initiator_user
@ -165,8 +166,8 @@ class TestProcessInstanceProcessor(BaseTest):
assert len(process_instance.active_tasks) == 1
active_task = process_instance.active_tasks[0]
assert active_task.lane_assignment_id is None
assert len(active_task.potential_owners) == 1
assert active_task.potential_owners[0] == finance_user
assert len(active_task.potential_owners) == 2
assert active_task.potential_owners == [finance_user_three, finance_user_four]
spiff_task = processor.__class__.get_task_by_bpmn_identifier(
active_task.task_name, processor.bpmn_process_instance
@ -177,7 +178,24 @@ class TestProcessInstanceProcessor(BaseTest):
)
ProcessInstanceService.complete_form_task(
processor, spiff_task, {}, finance_user
processor, spiff_task, {}, finance_user_three
)
assert len(process_instance.active_tasks) == 1
active_task = process_instance.active_tasks[0]
assert active_task.lane_assignment_id is None
assert len(active_task.potential_owners) == 1
assert active_task.potential_owners[0] == finance_user_four
spiff_task = processor.__class__.get_task_by_bpmn_identifier(
active_task.task_name, processor.bpmn_process_instance
)
with pytest.raises(UserDoesNotHaveAccessToTaskError):
ProcessInstanceService.complete_form_task(
processor, spiff_task, {}, initiator_user
)
ProcessInstanceService.complete_form_task(
processor, spiff_task, {}, finance_user_four
)
assert len(process_instance.active_tasks) == 1
active_task = process_instance.active_tasks[0]