Example #1
0
def type_names():
    api = system_util.pillar_api()

    types = NodeType.all(api=api)["_items"]
    type_names = []
    for names in types:
        type_names.append(str(names['name']))
    return type_names
Example #2
0
def type_names():
    api = SystemUtility.attract_api()

    types = NodeType.all(api=api)["_items"]
    type_names = []
    for names in types:
        type_names.append(str(names["name"]))
    return type_names
Example #3
0
def type_names():
    api = SystemUtility.attract_api()

    types = NodeType.all(api=api)["_items"]
    type_names = []
    for names in types:
        type_names.append(str(names['name']))
    return type_names
Example #4
0
def tasks():
    """User-assigned tasks"""
    # Pagination index
    page = request.args.get('page', 1)
    max_results = 50

    api = system_util.pillar_api()
    node_type_list = NodeType.all({'where': "name=='task'"}, api=api)

    if len(node_type_list['_items']) == 0:
        return "Empty NodeType list", 200

    node_type = node_type_list._items[0]

    tasks = Node.all({
        'where': '{"node_type" : "%s", "properties.owners.users": {"$in": ["%s"]}}'\
                % (node_type['_id'], current_user.objectid),
        'max_results': max_results,
        'page': page,
        'embedded': '{"parent":1, "picture":1}',
        'sort' : "order"}, api=api)

    # Build the pagination object
    # pagination = Pagination(int(page), max_results, tasks._meta.total)

    tasks_datatable = []
    for task in tasks._items:
        cut_in = 0
        cut_out = 0
        if task.parent.properties.cut_in:
            cut_in = task.parent.properties.cut_in
        if task.parent.properties.cut_out:
            cut_out = task.parent.properties.cut_out
        data = {
            'DT_RowId': "row_{0}".format(task._id),
            '_id': task._id,
            'order': task.order,
            'picture': None,
            'name': task.name,
            'timing': {
                'cut_in': task.parent.properties.cut_in,
                'cut_out': task.parent.properties.cut_out,
            },
            'parent': task.parent.to_dict(),
            'description': task.description,
            'url_view': url_for('nodes.view', node_id=task._id),
            'url_edit': url_for('nodes.edit', node_id=task._id, embed=1),
            'status': task.properties.status,
            }

        tasks_datatable.append(data)

    return render_template(
        'users/tasks.html',
        title="task",
        tasks_data=json.dumps(tasks_datatable),
        node_type=node_type)
Example #5
0
def tasks():
    """User-assigned tasks"""
    # Pagination index
    page = request.args.get("page", 1)
    max_results = 50

    api = SystemUtility.attract_api()
    node_type_list = NodeType.all({"where": "name=='task'"}, api=api)

    if len(node_type_list["_items"]) == 0:
        return "Empty NodeType list", 200

    node_type = node_type_list._items[0]

    tasks = Node.all(
        {
            "where": '{"node_type" : "%s", "properties.owners.users": {"$in": ["%s"]}}'
            % (node_type["_id"], current_user.objectid),
            "max_results": max_results,
            "page": page,
            "embedded": '{"parent":1, "picture":1}',
            "sort": "order",
        },
        api=api,
    )

    # Build the pagination object
    # pagination = Pagination(int(page), max_results, tasks._meta.total)

    tasks_datatable = []
    for task in tasks._items:
        cut_in = 0
        cut_out = 0
        if task.parent.properties.cut_in:
            cut_in = task.parent.properties.cut_in
        if task.parent.properties.cut_out:
            cut_out = task.parent.properties.cut_out
        data = {
            "DT_RowId": "row_{0}".format(task._id),
            "_id": task._id,
            "order": task.order,
            "picture": None,
            "name": task.name,
            "timing": {"cut_in": task.parent.properties.cut_in, "cut_out": task.parent.properties.cut_out},
            "parent": task.parent.to_dict(),
            "description": task.description,
            "url_view": url_for("nodes.view", node_id=task._id),
            "url_edit": url_for("nodes.edit", node_id=task._id, embed=1),
            "status": task.properties.status,
        }

        tasks_datatable.append(data)

    return render_template(
        "users/tasks.html", title="task", tasks_data=json.dumps(tasks_datatable), node_type=node_type
    )