Page MenuHome

tasks.py
No OneTemporary

tasks.py

import logging
from flask import Blueprint, render_template, request, current_app
import flask
import flask_login
import pillarsdk
from pillar.web.system_util import pillar_api
from .modules import attract_project_view
from .node_types.task import node_type_task
from . import current_task_manager
blueprint = Blueprint('attract.tasks', __name__, url_prefix='/tasks')
log = logging.getLogger(__name__)
@blueprint.route('/')
def index():
return render_template('attract/tasks/index.html')
@blueprint.route('/<project_url>/')
@attract_project_view()
def for_project(project):
api = pillar_api()
tasks = pillarsdk.Node.all({
'where': {
'project': project['_id'],
'node_type': node_type_task['name'],
}}, api=api)
return render_template('attract/tasks/for_project.html',
tasks=tasks['_items'],
project=project)
@blueprint.route('/<project_url>/<task_id>')
@attract_project_view()
def view_embed_task(project, task_id):
api = pillar_api()
task = pillarsdk.Node.find(task_id, api=api)
node_type = project.get_node_type(node_type_task['name'])
return render_template('attract/tasks/view_task_embed.html',
task=task,
project=project,
task_node_type=node_type)
@blueprint.route('/<project_url>/<task_id>', methods=['POST'])
@attract_project_view()
def save(project, task_id):
log.info('Saving task %s', task_id)
log.debug('Form data: %s', request.form)
task = current_task_manager.edit_task(task_id, **request.form.to_dict())
return flask.jsonify({'task_id': task_id, 'etag': task._etag})
@blueprint.route('/<project_url>/create')
@attract_project_view()
def create_task(project):
task = current_task_manager.create_task(project)
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

File Metadata

Mime Type
text/x-python
Expires
Thu, Feb 2, 5:49 AM (2 d)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
8e/22/51706386d10bdd09eb826d2874db

Event Timeline