def task_add(): api = SystemUtility.attract_api() shot_id = request.form["shot_id"] task_name = request.form["task_name"] node_type_list = NodeType.all({"where": "name=='task'"}, api=api) node_type = node_type_list["_items"][0] node_type_id = node_type._id import datetime RFC1123_DATE_FORMAT = "%a, %d %b %Y %H:%M:%S GMT" node = Node() prop = {} prop["node_type"] = node_type_id prop["name"] = task_name prop["description"] = "" prop["user"] = current_user.objectid prop["parent"] = shot_id prop["properties"] = { "status": "todo", "owners": {"users": [], "groups": []}, "time": { "duration": 10, "start": datetime.datetime.strftime(datetime.datetime.now(), "%a, %d %b %Y %H:%M:%S GMT"), }, } post = node.post(prop, api=api) return jsonify(node.to_dict())
def task_add(): api = system_util.pillar_api() shot_id = request.form['shot_id'] task_name = request.form['task_name'] node_type_list = NodeType.all({ 'where': "name=='task'", }, api=api) node_type = node_type_list['_items'][0] node_type_id = node_type._id import datetime RFC1123_DATE_FORMAT = '%a, %d %b %Y %H:%M:%S GMT' node = Node() prop = {} prop['node_type'] = node_type_id prop['name'] = task_name prop['description'] = '' prop['user'] = current_user.objectid prop['parent'] = shot_id prop['properties'] = { 'status': 'todo', 'owners': { 'users': [], 'groups': []}, 'time': { 'duration': 10, 'start': datetime.datetime.strftime(datetime.datetime.now(), '%a, %d %b %Y %H:%M:%S GMT')} } post = node.post(prop, api=api) return jsonify(node.to_dict())
def node_to_id(node: pillarsdk.Node) -> dict: """Converts a Node to a dict we can store in an ID property. ID properties only support a handful of Python classes, so we have to convert datetime.datetime to a string and remove None values. """ def to_rna(value): if isinstance(value, dict): return {k: to_rna(v) for k, v in value.items()} if isinstance(value, datetime.datetime): return value.strftime(RFC1123_DATE_FORMAT) return value as_dict = to_rna(node.to_dict()) return pillarsdk.utils.remove_none_attributes(as_dict)
def task_add(): api = system_util.pillar_api() shot_id = request.form['shot_id'] task_name = request.form['task_name'] node_type_list = NodeType.all({ 'where': "name=='task'", }, api=api) node_type = node_type_list['_items'][0] node_type_id = node_type._id import datetime RFC1123_DATE_FORMAT = '%a, %d %b %Y %H:%M:%S GMT' node = Node() prop = {} prop['node_type'] = node_type_id prop['name'] = task_name prop['description'] = '' prop['user'] = current_user.objectid prop['parent'] = shot_id prop['properties'] = { 'status': 'todo', 'owners': { 'users': [], 'groups': [] }, 'time': { 'duration': 10, 'start': datetime.datetime.strftime(datetime.datetime.now(), '%a, %d %b %Y %H:%M:%S GMT') } } post = node.post(prop, api=api) return jsonify(node.to_dict())