From d0b009ef4d15da136b79b442b76a62be3721d8df Mon Sep 17 00:00:00 2001 From: Francesco Siddi Date: Wed, 18 May 2016 17:41:11 +0200 Subject: [PATCH] Utilities in manage.py to add node_types and update texture node_type --- pillar/manage.py | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/pillar/manage.py b/pillar/manage.py index 55b57483..f33ece69 100755 --- a/pillar/manage.py +++ b/pillar/manage.py @@ -699,5 +699,46 @@ def project_stats(): ]) +@manager.command +def add_node_types(): + """Add texture and group_texture node types to all projects""" + from manage_extra.node_types.texture import node_type_texture + from manage_extra.node_types.group_texture import node_type_group_texture + from application.utils import project_get_node_type + projects_collections = app.data.driver.db['projects'] + for project in projects_collections.find(): + print("Processing {}".format(project['_id'])) + if not project_get_node_type(project, 'group_texture'): + project['node_types'].append(node_type_group_texture) + print("Added node type: {}".format(node_type_group_texture['name'])) + if not project_get_node_type(project, 'texture'): + project['node_types'].append(node_type_texture) + print("Added node type: {}".format(node_type_texture['name'])) + projects_collections.update( + {'_id': project['_id']}, project) + + +@manager.command +def update_texture_node_type(): + """Update allowed values for textures node_types""" + projects_collections = app.data.driver.db['projects'] + for project in projects_collections.find(): + print("Processing {}".format(project['_id'])) + for node_type in project['node_types']: + if node_type['name'] == 'texture': + allowed = [ + 'color', + 'specular', + 'bump', + 'normal', + 'translucency', + 'emission', + 'alpha' + ] + node_type['dyn_schema']['files']['schema']['schema']['map_type']['allowed'] = allowed + projects_collections.update( + {'_id': project['_id']}, project) + + if __name__ == '__main__': manager.run()