New data structure for attachments.

This commit is contained in:
2016-10-25 15:24:06 +02:00
parent ff7101c3fe
commit 0929a80f2b
7 changed files with 436 additions and 32 deletions

View File

@@ -21,8 +21,13 @@ class ValidateCustomFields(Validator):
prop_type = schema_prop['type']
if prop_type == 'dict':
properties[prop] = self.convert_properties(
properties[prop], schema_prop['schema'])
try:
dict_valueschema = schema_prop['schema']
except KeyError:
# TODO: will be renamed to 'keyschema' in Cerberus 1.0
dict_valueschema = schema_prop['valueschema']
properties[prop] = self.convert_properties(properties[prop], dict_valueschema)
elif prop_type == 'list':
if properties[prop] in ['', '[]']:
properties[prop] = []

View File

@@ -17,7 +17,10 @@ _attachments_embedded_schema = {
'valueschema': {
'type': 'dict',
'schema': {
'oid': 'objectid',
'oid': {
'type': 'objectid',
'required': True,
},
'collection': {
'type': 'string',
'allowed': ['files'],

View File

@@ -90,3 +90,10 @@ def create_new_project(project_name, user_id, overrides):
log.info('Created project %s for user %s', project['_id'], user_id)
return project
def get_node_type(project, node_type_name):
"""Returns the named node type, or None if it doesn't exist."""
return next((nt for nt in project['node_types']
if nt['name'] == node_type_name), None)