From 62b72bfbb1da4dc93bc083539bed1f25edb4e04a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Thu, 22 Sep 2016 10:34:51 +0200 Subject: [PATCH] Allow task creation with parent. The parent (shot_id in this case) is passed to the task creation end-point. Also, the task type is now passed as form parameter, rather than on the URL. --- attract/static/js/tasks.js | 11 ++++++----- attract/tasks.py | 11 ++++++++--- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/attract/static/js/tasks.js b/attract/static/js/tasks.js index 43c912f..7e1189d 100644 --- a/attract/static/js/tasks.js +++ b/attract/static/js/tasks.js @@ -32,13 +32,14 @@ function task_create(shot_id, project_url, task_type) { if (console) console.log("task_create(", shot_id, project_url, task_type, ") called."); return; } - var base_url = '/attract/' + project_url + '/tasks/create'; + var url = '/attract/' + project_url + '/tasks/create'; - if (task_type) { - base_url += '/' + task_type; - } + data = { + task_type: task_type, + parent: shot_id, + }; - $.post(base_url, function(task_data) { + $.post(url, data, function(task_data) { task_open(task_data.task_id, project_url); }) .fail(function(xhr) { diff --git a/attract/tasks.py b/attract/tasks.py index 281ec7a..1ed7a6f 100644 --- a/attract/tasks.py +++ b/attract/tasks.py @@ -71,10 +71,15 @@ def save(project, task_id): @perproject_blueprint.route('/create', methods=['POST']) -@perproject_blueprint.route('/create/', methods=['POST']) @attract_project_view() -def create_task(project, task_type=None): - task = current_attract.task_manager.create_task(project, task_type=task_type) +def create_task(project): + + task_type = request.form['task_type'] + parent = request.form.get('parent', None) + + task = current_attract.task_manager.create_task(project, + task_type=task_type, + parent=parent) resp = flask.make_response() resp.headers['Location'] = flask.url_for('.view_embed_task',