From 6cff12318f5f7dcb72b8fdf6e8b4f42434f0c02b Mon Sep 17 00:00:00 2001 From: Abdelrahman Moustafa Date: Thu, 9 Jan 2025 12:05:01 +0100 Subject: [PATCH] Implement auto-open of next task after closing the previous one --- changes/TI-1331.other | 1 + .../api/tests/test_task_from_template.py | 36 ------------------- opengever/task/handlers.py | 9 +++-- .../task/tests/test_task_from_template.py | 35 +++--------------- 4 files changed, 9 insertions(+), 72 deletions(-) create mode 100644 changes/TI-1331.other diff --git a/changes/TI-1331.other b/changes/TI-1331.other new file mode 100644 index 00000000000..4e00ba8d9ba --- /dev/null +++ b/changes/TI-1331.other @@ -0,0 +1 @@ +The next task in the sequence of the standard process can only be automatically opened after the responsible person closes the previous task. [amo] diff --git a/opengever/api/tests/test_task_from_template.py b/opengever/api/tests/test_task_from_template.py index 23d958d4e0a..28251f36a16 100644 --- a/opengever/api/tests/test_task_from_template.py +++ b/opengever/api/tests/test_task_from_template.py @@ -32,23 +32,6 @@ def setUp(self): self.seq_subtask_1.task_documents()) self.assertItemsEqual([], self.seq_subtask_2.task_documents()) - @browsing - def test_can_pass_documents_to_next_task_with_open_resolved_transition(self, browser): - self.login(self.secretariat_user, browser=browser) - - ITask(self.seq_subtask_1).task_type = 'correction' - url = '{}/@workflow/task-transition-open-resolved'.format( - self.seq_subtask_1.absolute_url()) - data = {'pass_documents_to_next_task': True} - - browser.open(url, method='POST', data=json.dumps(data), - headers=self.api_headers) - - self.assertEqual(200, browser.status_code) - self.assertItemsEqual( - [self.document, self.seq_subtask_1_document], - [item.to_object for item in ITask(self.seq_subtask_2).relatedItems]) - @browsing def test_can_pass_documents_to_next_task_with_open_tested_and_closed_transition(self, browser): self.login(self.secretariat_user, browser=browser) @@ -65,25 +48,6 @@ def test_can_pass_documents_to_next_task_with_open_tested_and_closed_transition( [self.document, self.seq_subtask_1_document], [item.to_object for item in ITask(self.seq_subtask_2).relatedItems]) - @browsing - def test_can_pass_documents_to_next_task_with_in_progress_resolved_transition(self, browser): - self.login(self.secretariat_user, browser=browser) - - ITask(self.seq_subtask_1).task_type = 'correction' - api.content.transition(obj=self.seq_subtask_1, transition='task-transition-open-in-progress') - - url = '{}/@workflow/task-transition-in-progress-resolved'.format( - self.seq_subtask_1.absolute_url()) - data = {'pass_documents_to_next_task': True} - - browser.open(url, method='POST', data=json.dumps(data), - headers=self.api_headers) - - self.assertEqual(200, browser.status_code) - self.assertItemsEqual( - [self.document, self.seq_subtask_1_document], - [item.to_object for item in ITask(self.seq_subtask_2).relatedItems]) - @browsing def test_can_pass_documents_to_next_task_with_in_progress_tested_and_closed_transition(self, browser): self.login(self.secretariat_user, browser=browser) diff --git a/opengever/task/handlers.py b/opengever/task/handlers.py index 9d2a33e7df4..295cadfab46 100644 --- a/opengever/task/handlers.py +++ b/opengever/task/handlers.py @@ -101,7 +101,6 @@ def review_state_changed(task, event): # on the parent task. We need to ensure, that every parent task is in progress. if event.action not in ['task-transition-open-planned', 'task-transition-planned-open', - 'task-transition-rejected-skipped', 'task-transition-reassign']: task.maybe_start_parent_task() @@ -111,11 +110,11 @@ def review_state_changed(task, event): task.close_main_task() return - if event.action not in ['task-transition-open-resolved', - 'task-transition-open-tested-and-closed', - 'task-transition-in-progress-resolved', + if event.action not in ['task-transition-open-tested-and-closed', + 'task-transition-resolved-tested-and-closed', 'task-transition-in-progress-tested-and-closed', - 'task-transition-rejected-skipped']: + 'task-transition-rejected-skipped' + ]: return if task.is_part_of_sequential_process: diff --git a/opengever/task/tests/test_task_from_template.py b/opengever/task/tests/test_task_from_template.py index 57039ad7f94..a9f8931afec 100644 --- a/opengever/task/tests/test_task_from_template.py +++ b/opengever/task/tests/test_task_from_template.py @@ -22,33 +22,6 @@ class TestSequentialTaskProcess(IntegrationTestCase): features = ('activity', ) - def test_starts_next_task_when_task_gets_resolved(self): - self.login(self.regular_user) - - # create subtask - subtask2 = create(Builder('task') - .within(self.task) - .having(responsible_client='fa', - responsible=self.regular_user.getId(), - issuer=self.dossier_responsible.getId(), - task_type='correction', - deadline=date(2016, 11, 1)) - .in_state('task-state-planned')) - - self.set_workflow_state('task-state-in-progress', self.subtask) - alsoProvides(self.task, IContainSequentialProcess) - alsoProvides(self.subtask, IPartOfSequentialProcess) - alsoProvides(subtask2, IPartOfSequentialProcess) - self.task.set_tasktemplate_order([self.subtask, subtask2]) - - api.content.transition( - obj=self.subtask, transition='task-transition-in-progress-resolved') - - self.assertEquals( - 'task-state-resolved', api.content.get_state(self.subtask)) - self.assertEquals( - 'task-state-open', api.content.get_state(subtask2)) - def test_starts_next_task_when_task_gets_closed(self): self.login(self.regular_user) @@ -267,7 +240,7 @@ def test_handles_missing_permissions_on_next_task(self): self.assertEquals( 'task-state-resolved', api.content.get_state(subtask1)) self.assertEquals( - 'task-state-open', api.content.get_state(subtask2)) + 'task-state-planned', api.content.get_state(subtask2)) def test_record_activity_when_open_next_task(self): self.login(self.regular_user) @@ -296,7 +269,7 @@ def test_record_activity_when_open_next_task(self): self.assertEquals( 'task-state-resolved', api.content.get_state(self.subtask)) self.assertEquals( - 'task-state-open', api.content.get_state(subtask2)) + 'task-state-planned', api.content.get_state(subtask2)) activities = Resource.query.get_by_oguid( Oguid.for_object(subtask2)).activities @@ -680,13 +653,13 @@ def test_closes_main_task_if_all_subtasks_are_in_final_state(self): 'task-state-in-progress', api.content.get_state(self.sequential_task)) api.content.transition( - obj=self.seq_subtask_3, transition='task-transition-open-tested-and-closed') + obj=self.seq_subtask_1, transition='task-transition-resolved-tested-and-closed') self.assertEquals( 'task-state-in-progress', api.content.get_state(self.sequential_task)) api.content.transition( - obj=self.seq_subtask_1, transition='task-transition-resolved-tested-and-closed') + obj=self.seq_subtask_3, transition='task-transition-open-tested-and-closed') self.assertEquals( 'task-state-tested-and-closed', api.content.get_state(self.sequential_task))