Added rudimentary entry point for texture libraries.

It returns those project the user has access to that also have defined
a 'texture' node type. It should also only return those projects that
actually have a 'group_texture' node type defined, and have one more
more 'texture' nodes (i.e. projects that don't contain texture nodes
should not be returned).
This commit is contained in:
Sybren A. Stüvel 2016-05-17 17:59:14 +02:00
parent 81105102f4
commit e35b7711a3
2 changed files with 28 additions and 0 deletions

View File

@ -199,6 +199,7 @@ from modules import file_storage
from modules import users from modules import users
from modules import nodes from modules import nodes
from modules import latest from modules import latest
from modules import blender_cloud
app.register_blueprint(encoding, url_prefix='/encoding') app.register_blueprint(encoding, url_prefix='/encoding')
app.register_blueprint(blender_id, url_prefix='/blender_id') app.register_blueprint(blender_id, url_prefix='/blender_id')
@ -206,5 +207,6 @@ projects.setup_app(app, url_prefix='/p')
local_auth.setup_app(app, url_prefix='/auth') local_auth.setup_app(app, url_prefix='/auth')
file_storage.setup_app(app, url_prefix='/storage') file_storage.setup_app(app, url_prefix='/storage')
latest.setup_app(app, url_prefix='/latest') latest.setup_app(app, url_prefix='/latest')
blender_cloud.setup_app(app, url_prefix='/bcloud')
users.setup_app(app) users.setup_app(app)
nodes.setup_app(app) nodes.setup_app(app)

View File

@ -0,0 +1,26 @@
from flask import Blueprint, request
from eve.methods.get import get
from eve.utils import config as eve_config
from application import utils
TEXTURE_LIBRARY_QUERY_ARGS = {
eve_config.QUERY_PROJECTION: utils.dumps({
'name': 1, 'url': 1, 'permissions': 1, 'node_types.name': 1,}),
eve_config.QUERY_SORT: utils.dumps([('name', 1)]),
'max_results': 'null',}
blueprint = Blueprint('blender_cloud', __name__)
@blueprint.route('/texture-libraries')
def texture_libraries():
# Use Eve method so that we get filtering on permissions for free.
request.args = TEXTURE_LIBRARY_QUERY_ARGS
projects = get('projects', {'node_types.name': 'texture'})
return utils.jsonify(projects)
def setup_app(app, url_prefix):
app.register_blueprint(blueprint, url_prefix=url_prefix)