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( self.raise_if_no_potential_owners(
potential_owner_ids, potential_owner_ids,
f"No users found in task data lane owner list for lane: {task_lane}. " 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]}",
=======
f"The user list used: {task.data['lane_owners'][task_lane]}"
>>>>>>> Stashed changes
) )
else: else:
group_model = GroupModel.query.filter_by(identifier=task_lane).first() 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 i.user_id for i in group_model.user_group_assignments
] ]
lane_assignment_id = group_model.id lane_assignment_id = group_model.id
<<<<<<< Updated upstream
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}",
) )
=======
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 { return {
"potential_owner_ids": potential_owner_ids, "potential_owner_ids": potential_owner_ids,
@ -597,9 +605,14 @@ class ProcessInstanceProcessor:
# filter out non-usertasks # filter out non-usertasks
task_spec = ready_or_waiting_task.task_spec task_spec = ready_or_waiting_task.task_spec
if not self.bpmn_process_instance._is_engine_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( potential_owner_hash = self.get_potential_owner_ids_from_task(
ready_or_waiting_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 extensions = ready_or_waiting_task.task_spec.extensions
form_file_name = None form_file_name = None

View File

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

View File

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