mirror of
https://github.com/wagtail/wagtail.git
synced 2024-11-30 11:10:43 +01:00
replace get_task_result_data helper with more useful one get_task_chosen_response
This commit is contained in:
parent
2af6b35203
commit
60ba39ffb5
@ -485,17 +485,19 @@ def enable_task(request, pk):
|
|||||||
return redirect('wagtailadmin_workflows:edit_task', task.id)
|
return redirect('wagtailadmin_workflows:edit_task', task.id)
|
||||||
|
|
||||||
|
|
||||||
def get_task_result_data(task):
|
def get_task_chosen_response(request, task):
|
||||||
"""
|
"""
|
||||||
helper function: given a task, return the json data to pass back to the
|
helper function: given a task, return the response indicating that it has been chosen
|
||||||
chooser panel
|
|
||||||
"""
|
"""
|
||||||
|
result_data = {
|
||||||
return {
|
|
||||||
'id': task.id,
|
'id': task.id,
|
||||||
'name': task.name,
|
'name': task.name,
|
||||||
'edit_url': reverse('wagtailadmin_workflows:edit_task', args=[task.id]),
|
'edit_url': reverse('wagtailadmin_workflows:edit_task', args=[task.id]),
|
||||||
}
|
}
|
||||||
|
return render_modal_workflow(
|
||||||
|
request, None, None,
|
||||||
|
None, json_data={'step': 'task_chosen', 'result': result_data}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class BaseTaskChooserView(View):
|
class BaseTaskChooserView(View):
|
||||||
@ -576,13 +578,7 @@ class TaskChooserView(BaseTaskChooserView):
|
|||||||
|
|
||||||
if self.createform.is_valid():
|
if self.createform.is_valid():
|
||||||
task = self.createform.save()
|
task = self.createform.save()
|
||||||
|
return get_task_chosen_response(request, task)
|
||||||
response = render_modal_workflow(
|
|
||||||
request, None, None,
|
|
||||||
None, json_data={'step': 'task_chosen', 'result': get_task_result_data(task)}
|
|
||||||
)
|
|
||||||
|
|
||||||
return response
|
|
||||||
else:
|
else:
|
||||||
return self.render_to_response()
|
return self.render_to_response()
|
||||||
|
|
||||||
@ -646,8 +642,4 @@ class TaskChooserResultsView(BaseTaskChooserView):
|
|||||||
|
|
||||||
def task_chosen(request, task_id):
|
def task_chosen(request, task_id):
|
||||||
task = get_object_or_404(Task, id=task_id)
|
task = get_object_or_404(Task, id=task_id)
|
||||||
|
return get_task_chosen_response(request, task)
|
||||||
return render_modal_workflow(
|
|
||||||
request, None, None,
|
|
||||||
None, json_data={'step': 'task_chosen', 'result': get_task_result_data(task)}
|
|
||||||
)
|
|
||||||
|
Loading…
Reference in New Issue
Block a user