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.
This commit is contained in:
2016-09-22 10:34:51 +02:00
parent 00da55045a
commit 62b72bfbb1
2 changed files with 14 additions and 8 deletions

View File

@@ -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."); if (console) console.log("task_create(", shot_id, project_url, task_type, ") called.");
return; return;
} }
var base_url = '/attract/' + project_url + '/tasks/create'; var url = '/attract/' + project_url + '/tasks/create';
if (task_type) { data = {
base_url += '/' + task_type; 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); task_open(task_data.task_id, project_url);
}) })
.fail(function(xhr) { .fail(function(xhr) {

View File

@@ -71,10 +71,15 @@ def save(project, task_id):
@perproject_blueprint.route('/create', methods=['POST']) @perproject_blueprint.route('/create', methods=['POST'])
@perproject_blueprint.route('/create/<task_type>', methods=['POST'])
@attract_project_view() @attract_project_view()
def create_task(project, task_type=None): def create_task(project):
task = current_attract.task_manager.create_task(project, task_type=task_type)
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 = flask.make_response()
resp.headers['Location'] = flask.url_for('.view_embed_task', resp.headers['Location'] = flask.url_for('.view_embed_task',