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 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 index(): """Display the node types """ node_types = NodeType.all() node_types = node_types['_items'] return render_template('node_types/index.html', title='node_types', node_types=node_types)
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
def index(): """Display the node types """ api = system_util.pillar_api() node_types = NodeType.all(api=api) node_types = node_types['_items'] return render_template('node_types/index.html', title='node_types', node_types=node_types)
def inject_node_types(): if current_user.is_anonymous: return dict(node_types={}) api = SystemUtility.attract_api() types = NodeType.all(api=api)['_items'] node_types = [] for t in types: # If we need to include more info, we can turn node_types into a dict # node_types[t.name] = dict( # url_view=url_for('nodes.index', node_type_name=t.name)) node_types.append(str(t['name'])) return dict(node_types=node_types)
def index(): """Custom production stats entry point """ api = SystemUtility.attract_api() node_type_list = NodeType.all( {'where': '{"name": "%s"}' % ('shot')}, api=api) node_type = node_type_list['_items'][0] nodes = Node.all({ 'where': '{"node_type": "%s"}' % (node_type['_id']), 'max_results': 100, 'sort' : "order"}, api=api) node_statuses = {} node_totals = { 'count': 0, 'frames': 0 } for shot in nodes._items: status = shot.properties.status if status not in node_statuses: # If they key does not exist, initialize with defaults node_statuses[status] = { 'count': 0, 'frames': 0} # Calculate shot duration and increase status count frames = shot.properties.cut_out - shot.properties.cut_in node_statuses[status]['count'] += 1 node_statuses[status]['frames'] += frames # Update the global stats node_totals['count'] += 1 node_totals['frames'] += frames for node_status in node_statuses: # Calculate completion percentage based on total duration print node_statuses[node_status]['frames'] print node_totals['frames'] node_statuses[node_status]['completion'] = percentage( node_statuses[node_status]['frames'], node_totals['frames']) return render_template( 'stats/index.html', node_statuses=node_statuses)
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 shots_index(): max_results = 100 api = system_util.pillar_api() node_type_name = "shot" node_type_list = NodeType.all({ 'where': '{"name" : "%s"}' % node_type_name, }, api=api) node_type = node_type_list._items[0] nodes = Node.all({ 'where': '{"node_type" : "%s"}' % node_type._id, 'max_results': max_results, 'embedded': '{"picture":1}', 'sort' : "order"}, api=api) # Get the task node type object id node_type_list = NodeType.all({ 'where': '{"name" : "task"}', }, api=api) node_type_task = node_type_list._items[0] nodes_datatables = [] for node in nodes._items: tasks = Node.all({ 'where': '{"node_type" : "%s", "parent" : "%s"}'\ % (node_type_task._id, node._id), 'sort' : "order"}, api=api) shot_status = None try: shot_status = node.properties.status except: # Notify about missing status property. This should be prominent. pass data = { 'DT_RowId': "row_{0}".format(node._id), 'DT_RowAttr': {'data-shot-status':shot_status}, '_id': node._id, 'order': node.order, 'picture': None, 'name': node.name, #'description': node.description, 'notes': node.properties.notes, 'timing': { 'cut_in': node.properties.cut_in, 'cut_out': node.properties.cut_out }, 'url_view': url_for('nodes.view', node_id=node._id), 'url_edit': url_for('nodes.edit', node_id=node._id, embed=1), 'tasks': { 'animation': None, 'lighting': None, 'fx_hair': None, 'fx_grass': None, 'fx_smoke': None }, } if node.picture: # This is an address on the Attract server, so it should be built # entirely here data['picture'] = "{0}/file_server/file/{1}".format( app.config['PILLAR_SERVER_ENDPOINT'], node.picture.path) # Get previews picture_node = File.find(node.picture['_id'] + \ '/?embedded={"previews":1}', api=api) if picture_node.previews: for preview in picture_node.previews: if preview.size == 'm': data['picture_thumbnail'] = app.config['PILLAR_SERVER_ENDPOINT'] + "/file_server/file/" + preview.path break else: data['picture_thumbnail'] = data['picture'] if node.order is None: data['order'] = 0 for task in tasks._items: # If there are tasks assigned to the shot we loop through them and # match them with the existing data indexes. if task.name in data['tasks']: data['tasks'][task.name] = { 'name': task.name, 'status': task.properties.status, 'url_view': url_for('nodes.view', node_id=task._id, embed=1), 'url_edit': url_for('nodes.edit', node_id=task._id, embed=1), 'is_conflicting': task.properties.is_conflicting, 'is_processing': task.properties.is_rendering, 'is_open': task.properties.is_open } nodes_datatables.append(data) return jsonify(data=nodes_datatables)
def shots_index(): max_results = 100 api = system_util.pillar_api() node_type_name = "shot" node_type_list = NodeType.all( { 'where': '{"name" : "%s"}' % node_type_name, }, api=api) node_type = node_type_list._items[0] nodes = Node.all( { 'where': '{"node_type" : "%s"}' % node_type._id, 'max_results': max_results, 'embedded': '{"picture":1}', 'sort': "order" }, api=api) # Get the task node type object id node_type_list = NodeType.all({ 'where': '{"name" : "task"}', }, api=api) node_type_task = node_type_list._items[0] nodes_datatables = [] for node in nodes._items: tasks = Node.all({ 'where': '{"node_type" : "%s", "parent" : "%s"}'\ % (node_type_task._id, node._id), 'sort' : "order"}, api=api) shot_status = None try: shot_status = node.properties.status except: # Notify about missing status property. This should be prominent. pass data = { 'DT_RowId': "row_{0}".format(node._id), 'DT_RowAttr': { 'data-shot-status': shot_status }, '_id': node._id, 'order': node.order, 'picture': None, 'name': node.name, #'description': node.description, 'notes': node.properties.notes, 'timing': { 'cut_in': node.properties.cut_in, 'cut_out': node.properties.cut_out }, 'url_view': url_for('nodes.view', node_id=node._id), 'url_edit': url_for('nodes.edit', node_id=node._id, embed=1), 'tasks': { 'animation': None, 'lighting': None, 'fx_hair': None, 'fx_grass': None, 'fx_smoke': None }, } if node.picture: # This is an address on the Attract server, so it should be built # entirely here data['picture'] = "{0}/file_server/file/{1}".format( app.config['PILLAR_SERVER_ENDPOINT'], node.picture.path) # Get previews picture_node = File.find(node.picture['_id'] + \ '/?embedded={"previews":1}', api=api) if picture_node.previews: for preview in picture_node.previews: if preview.size == 'm': data['picture_thumbnail'] = app.config[ 'PILLAR_SERVER_ENDPOINT'] + "/file_server/file/" + preview.path break else: data['picture_thumbnail'] = data['picture'] if node.order is None: data['order'] = 0 for task in tasks._items: # If there are tasks assigned to the shot we loop through them and # match them with the existing data indexes. if task.name in data['tasks']: data['tasks'][task.name] = { 'name': task.name, 'status': task.properties.status, 'url_view': url_for('nodes.view', node_id=task._id, embed=1), 'url_edit': url_for('nodes.edit', node_id=task._id, embed=1), 'is_conflicting': task.properties.is_conflicting, 'is_processing': task.properties.is_rendering, 'is_open': task.properties.is_open } nodes_datatables.append(data) return jsonify(data=nodes_datatables)
def index(): """Display the node types """ node_types = NodeType.all() node_types = node_types["_items"] return render_template("node_types/index.html", title="node_types", node_types=node_types)