Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement auto-open of next task after closing the previous one #8107

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changes/TI-1331.other
Original file line number Diff line number Diff line change
@@ -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]
36 changes: 0 additions & 36 deletions opengever/api/tests/test_task_from_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
9 changes: 4 additions & 5 deletions opengever/task/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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:
Expand Down
35 changes: 4 additions & 31 deletions opengever/task/tests/test_task_from_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand Down