Added async task loading

This commit is contained in:
2016-09-07 15:08:49 +02:00
parent 805f56d6f4
commit 3c09586349
3 changed files with 55 additions and 15 deletions

View File

@@ -24,12 +24,13 @@ def for_project(project):
api = pillar_api()
tasks = pillarsdk.Node.all({
'project': project['_id'],
'node_type': 'attract.task',
}, api=api)
'where': {
'project': project['_id'],
'node_type': 'attract.task',
}}, api=api)
return render_template('attract/tasks/for_project.html',
tasks=tasks,
tasks=tasks['_items'],
project=project)
@@ -37,15 +38,17 @@ def for_project(project):
@attract_project_view()
def view_embed_task(project, task_id):
api = pillar_api()
task = pillarsdk.Node.find(task_id, api=api)
return 'Not done, come back later.'
return render_template('attract/tasks/view_task_embed.html',
task=task,
project=project)
@blueprint.route('/<project_url>/create')
@attract_project_view()
def create_task(project):
api = pillar_api()
node_type = project.get_node_type('attract.task')
node_props = dict(
@@ -61,6 +64,9 @@ def create_task(project):
task = pillarsdk.Node(node_props)
task.create(api=api)
return flask.redirect(flask.url_for('attract.tasks.view_embed_task',
project_url=project['url'],
task_id=task['_id']))
resp = flask.make_response()
resp.headers['Location'] = flask.url_for('attract.tasks.view_embed_task',
project_url=project['url'],
task_id=task['_id'])
resp.status_code = 201
return resp