From f72890cc59e4e2dbebb22c0d553f9c234535aab2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Tue, 25 Oct 2016 15:31:13 +0200 Subject: [PATCH] Define standard set of node types --- pillar/api/node_types/__init__.py | 19 ++++ pillar/tests/common_test_data.py | 176 ++++-------------------------- 2 files changed, 40 insertions(+), 155 deletions(-) diff --git a/pillar/api/node_types/__init__.py b/pillar/api/node_types/__init__.py index ddb8aede..cd66b2e0 100644 --- a/pillar/api/node_types/__init__.py +++ b/pillar/api/node_types/__init__.py @@ -29,3 +29,22 @@ _attachments_embedded_schema = { }, }, } + +# Import after defining the common embedded schemas, to prevent dependency cycles. +from pillar.api.node_types.asset import node_type_asset +from pillar.api.node_types.blog import node_type_blog +from pillar.api.node_types.comment import node_type_comment +from pillar.api.node_types.group import node_type_group +from pillar.api.node_types.group_hdri import node_type_group_hdri +from pillar.api.node_types.group_texture import node_type_group_texture +from pillar.api.node_types.hdri import node_type_hdri +from pillar.api.node_types.page import node_type_page +from pillar.api.node_types.post import node_type_post +from pillar.api.node_types.storage import node_type_storage +from pillar.api.node_types.text import node_type_text +from pillar.api.node_types.texture import node_type_texture + +PILLAR_NODE_TYPES = (node_type_asset, node_type_blog, node_type_comment, node_type_group, + node_type_group_hdri, node_type_group_texture, node_type_hdri, node_type_page, + node_type_post, node_type_storage, node_type_text, node_type_texture) +PILLAR_NAMED_NODE_TYPES = {nt['name']: nt for nt in PILLAR_NODE_TYPES} diff --git a/pillar/tests/common_test_data.py b/pillar/tests/common_test_data.py index 1d6bde6b..e39ad214 100644 --- a/pillar/tests/common_test_data.py +++ b/pillar/tests/common_test_data.py @@ -2,6 +2,8 @@ import datetime from bson import tz_util, ObjectId +from pillar.api.node_types import PILLAR_NAMED_NODE_TYPES + EXAMPLE_ADMIN_GROUP_ID = ObjectId('5596e975ea893b269af85c0e') EXAMPLE_PROJECT_READONLY_GROUP_ID = ObjectId('5596e975ea893b269af85c0f') EXAMPLE_PROJECT_READONLY_GROUP2_ID = ObjectId('564733b56dcaf85da2faee8a') @@ -46,163 +48,27 @@ EXAMPLE_PROJECT = { u'_id': EXAMPLE_PROJECT_ID, u'_updated': datetime.datetime(2016, 1, 7, 18, 59, 4, tzinfo=tz_util.utc), u'category': u'assets', - u'description': u'Welcome to this curated collection of Blender Institute textures and image resources. This collection is an on-going project, as with each project we create a number of textures based on our own resources (photographs, scans, etc.) or made completely from scratch. At the moment you can find all the textures from the past Open Projects that were deemed re-usable. \r\n\r\nPeople who have contributed to these textures:\r\n\r\nAndrea Weikert, Andy Goralczyk, Basse Salmela, Ben Dansie, Campbell Barton, Enrico Valenza, Ian Hubert, Kjartan Tysdal, Manu J\xe4rvinen, Massimiliana Pulieso, Matt Ebb, Pablo Vazquez, Rob Tuytel, Roland Hess, Sarah Feldlaufer, S\xf6nke M\xe4ter', + u'description': u'Welcome to this curated collection of Blender Institute textures and image ' + u'resources. This collection is an on-going project, as with each project we ' + u'create a number of textures based on our own resources (photographs, scans, ' + u'etc.) or made completely from scratch. At the moment you can find all the ' + u'textures from the past Open Projects that were deemed re-usable. \r\n\r\n' + u'People who have contributed to these textures:\r\n\r\nAndrea Weikert, Andy ' + u'Goralczyk, Basse Salmela, Ben Dansie, Campbell Barton, Enrico Valenza, Ian ' + u'Hubert, Kjartan Tysdal, Manu J\xe4rvinen, Massimiliana Pulieso, Matt Ebb, ' + u'Pablo Vazquez, Rob Tuytel, Roland Hess, Sarah Feldlaufer, S\xf6nke M\xe4ter', u'is_private': False, u'name': u'Unittest project', - u'node_types': [{u'description': u'Group for texture node type', - u'dyn_schema': {u'order': {u'type': u'integer'}, - u'status': {u'allowed': [u'published', u'pending'], - u'type': u'string'}, - u'url': {u'type': u'string'}}, - u'form_schema': {}, - u'name': u'group_texture', - u'parent': [u'group_texture', u'project']}, - {u'description': u'Generic group node type edited', - u'dyn_schema': {u'notes': {u'maxlength': 256, u'type': u'string'}, - u'order': {u'type': u'integer'}, - u'status': {u'allowed': [u'published', u'pending'], - u'type': u'string'}, - u'url': {u'type': u'string'}}, - u'form_schema': {}, - u'name': u'group', - u'parent': [u'group', u'project']}, - {u'description': u'Basic Asset Type', - u'dyn_schema': { - u'attachments': {u'schema': {u'schema': {u'field': {u'type': u'string'}, - u'files': {u'schema': { - u'schema': {u'file': { - u'data_relation': { - u'embeddable': True, - u'field': u'_id', - u'resource': u'files'}, - u'type': u'objectid'}, - u'size': { - u'type': u'string'}, - u'slug': { - u'minlength': 1, - u'type': u'string'}}, - u'type': u'dict'}, - u'type': u'list'}}, - u'type': u'dict'}, - u'type': u'list'}, - u'categories': {u'type': u'string'}, - u'content_type': {u'type': u'string'}, - u'file': {u'data_relation': {u'embeddable': True, - u'field': u'_id', - u'resource': u'files'}, - u'type': u'objectid'}, - u'order': {u'type': u'integer'}, - u'status': {u'allowed': [u'published', - u'pending', - u'processing'], - u'type': u'string'}, - u'tags': {u'schema': {u'type': u'string'}, u'type': u'list'}}, - u'form_schema': {u'attachments': {u'visible': False}, - u'content_type': {u'visible': False}, - u'file': {u'visible': False}}, - u'name': u'asset', - u'parent': [u'group']}, - {u'description': u'Entrypoint to a remote or local storage solution', - u'dyn_schema': {u'backend': {u'type': u'string'}, - u'subdir': {u'type': u'string'}}, - u'form_schema': {u'backend': {}, u'subdir': {}}, - u'name': u'storage', - u'parent': [u'group', u'project'], - u'permissions': {u'groups': [{u'group': EXAMPLE_ADMIN_GROUP_ID, - u'methods': [u'GET', u'PUT', u'POST']}, - {u'group': EXAMPLE_PROJECT_READONLY_GROUP_ID, - u'methods': [u'GET']}, - {u'group': EXAMPLE_PROJECT_READONLY_GROUP2_ID, - u'methods': [u'GET']}], - u'users': [], - u'world': []}}, - {u'description': u'Comments for asset nodes, pages, etc.', - u'dyn_schema': {u'confidence': {u'type': u'float'}, - u'content': {u'minlength': 5, u'type': u'string'}, - u'is_reply': {u'type': u'boolean'}, - u'rating_negative': {u'type': u'integer'}, - u'rating_positive': {u'type': u'integer'}, - u'ratings': {u'schema': { - u'schema': {u'is_positive': {u'type': u'boolean'}, - u'user': {u'type': u'objectid'}, - u'weight': {u'type': u'integer'}}, - u'type': u'dict'}, - u'type': u'list'}, - u'status': {u'allowed': [u'published', u'flagged', u'edited'], - u'type': u'string'}}, - u'form_schema': {}, - u'name': u'comment', - u'parent': [u'asset', u'comment']}, - {u'description': u'Container for node_type post.', - u'dyn_schema': {u'categories': {u'schema': {u'type': u'string'}, - u'type': u'list'}, - u'template': {u'type': u'string'}}, - u'form_schema': {}, - u'name': u'blog', - u'parent': [u'project']}, - {u'description': u'A blog post, for any project', - u'dyn_schema': { - u'attachments': {u'schema': {u'schema': {u'field': {u'type': u'string'}, - u'files': {u'schema': { - u'schema': {u'file': { - u'data_relation': { - u'embeddable': True, - u'field': u'_id', - u'resource': u'files'}, - u'type': u'objectid'}, - u'size': { - u'type': u'string'}, - u'slug': { - u'minlength': 1, - u'type': u'string'}}, - u'type': u'dict'}, - u'type': u'list'}}, - u'type': u'dict'}, - u'type': u'list'}, - u'category': {u'type': u'string'}, - u'content': {u'maxlength': 90000, - u'minlength': 5, - u'required': True, - u'type': u'string'}, - u'status': {u'allowed': [u'published', u'pending'], - u'default': u'pending', - u'type': u'string'}, - u'url': {u'type': u'string'}}, - u'form_schema': {u'attachments': {u'visible': False}}, - u'name': u'post', - u'parent': [u'blog']}, - {u'description': u'Image Texture', - u'dyn_schema': {u'aspect_ratio': {u'type': u'float'}, - u'categories': {u'type': u'string'}, - u'files': {u'schema': {u'schema': { - u'file': {u'data_relation': {u'embeddable': True, - u'field': u'_id', - u'resource': u'files'}, - u'type': u'objectid'}, - u'is_tileable': {u'type': u'boolean'}, - u'map_type': {u'allowed': [u'color', - u'specular', - u'bump', - u'normal', - u'translucency', - u'emission', - u'alpha'], - u'type': u'string'}}, - u'type': u'dict'}, - u'type': u'list'}, - u'is_landscape': {u'type': u'boolean'}, - u'is_tileable': {u'type': u'boolean'}, - u'order': {u'type': u'integer'}, - u'resolution': {u'type': u'string'}, - u'status': {u'allowed': [u'published', - u'pending', - u'processing'], - u'type': u'string'}, - u'tags': {u'schema': {u'type': u'string'}, u'type': u'list'}}, - u'form_schema': {u'content_type': {u'visible': False}, - u'files': {u'visible': False}}, - u'name': u'texture', - u'parent': [u'group']}], + u'node_types': [ + PILLAR_NAMED_NODE_TYPES['group_texture'], + PILLAR_NAMED_NODE_TYPES['group'], + PILLAR_NAMED_NODE_TYPES['asset'], + PILLAR_NAMED_NODE_TYPES['storage'], + PILLAR_NAMED_NODE_TYPES['comment'], + PILLAR_NAMED_NODE_TYPES['blog'], + PILLAR_NAMED_NODE_TYPES['post'], + PILLAR_NAMED_NODE_TYPES['texture'], + ], u'nodes_blog': [], u'nodes_featured': [], u'nodes_latest': [],