Beispiel #1
0
def task_create():
    """Add new task to a list."""
    task = Task(None)

    if request.method == "POST":
        content = request.get_json(silent=True)
        if not content:
            abort(400)
        task.from_dict(content)

    dynamo.tasks_master.put_item(data=task.as_dict())
    return "Task ID: %s" % task.get_id()
Beispiel #2
0
def task_search(owner):
    """Return list of Tasks wit specified owner."""
    data = {"items": []}
    length = 0

    data["table_name"] = "tasks_master"
    results = dynamo.tasks_master.query(owner__eq=owner,
                                        index='secondKeyIndex')
    for r in results:
        data["items"].append(dict(r.items()))

        t = Task("")
        t.from_dict(dict(r.items()))
        length += 1
    data["items_length"] = length

    if length < 1:
        abort(404)

    return json.dumps(data, indent=4, cls=DecimalEncoder)