2015-03-12 15:05:10 +01:00
|
|
|
import os
|
|
|
|
|
2015-03-10 11:38:57 +01:00
|
|
|
# Enable reads (GET), inserts (POST) and DELETE for resources/collections
|
|
|
|
# (if you omit this line, the API will default to ['GET'] and provide
|
|
|
|
# read-only access to the endpoint).
|
|
|
|
RESOURCE_METHODS = ['GET', 'POST', 'DELETE']
|
|
|
|
|
|
|
|
# Enable reads (GET), edits (PATCH), replacements (PUT) and deletes of
|
|
|
|
# individual items (defaults to read-only item access).
|
2015-04-15 16:21:38 +02:00
|
|
|
ITEM_METHODS = ['GET', 'PUT', 'DELETE', 'PATCH']
|
2015-03-10 11:38:57 +01:00
|
|
|
|
2015-04-16 14:29:44 +02:00
|
|
|
PAGINATION_LIMIT = 100
|
2015-03-10 11:38:57 +01:00
|
|
|
|
2015-04-22 08:51:01 -03:00
|
|
|
# To be implemented on Eve 0.6
|
|
|
|
# RETURN_MEDIA_AS_URL = True
|
|
|
|
|
2015-03-11 16:03:19 +01:00
|
|
|
users_schema = {
|
2015-04-16 15:28:28 +02:00
|
|
|
'first_name': {
|
2015-03-10 11:38:57 +01:00
|
|
|
'type': 'string',
|
|
|
|
'minlength': 1,
|
2015-04-09 19:06:10 -03:00
|
|
|
'maxlength': 60,
|
2015-03-10 11:38:57 +01:00
|
|
|
},
|
2015-04-16 15:28:28 +02:00
|
|
|
'last_name': {
|
2015-03-10 11:38:57 +01:00
|
|
|
'type': 'string',
|
|
|
|
'minlength': 1,
|
2015-04-09 19:06:10 -03:00
|
|
|
'maxlength': 60,
|
|
|
|
},
|
|
|
|
'email': {
|
|
|
|
'type': 'string',
|
|
|
|
'minlength': 1,
|
|
|
|
'maxlength': 60,
|
2015-03-10 11:38:57 +01:00
|
|
|
},
|
|
|
|
'role': {
|
2015-03-27 15:42:28 +01:00
|
|
|
'type': 'list',
|
|
|
|
'allowed': ["admin"],
|
2015-03-11 16:03:19 +01:00
|
|
|
'required': True,
|
2015-04-13 01:21:57 +02:00
|
|
|
}
|
2015-03-10 11:38:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
nodes_schema = {
|
|
|
|
'name': {
|
|
|
|
'type': 'string',
|
|
|
|
'minlength': 1,
|
|
|
|
'maxlength': 128,
|
2015-03-11 16:03:19 +01:00
|
|
|
'required': True,
|
|
|
|
},
|
|
|
|
'description': {
|
|
|
|
'type': 'string',
|
2015-03-27 15:42:28 +01:00
|
|
|
'minlength': 0,
|
2015-03-11 16:03:19 +01:00
|
|
|
'maxlength': 128,
|
|
|
|
},
|
2015-04-13 01:21:57 +02:00
|
|
|
'picture': {
|
2015-04-16 15:02:32 -03:00
|
|
|
'type': 'objectid',
|
|
|
|
'nullable': True,
|
2015-03-10 11:38:57 +01:00
|
|
|
},
|
2015-03-27 15:42:28 +01:00
|
|
|
'order': {
|
|
|
|
'type': 'integer',
|
|
|
|
'minlength': 0,
|
|
|
|
},
|
2015-03-10 11:38:57 +01:00
|
|
|
'parent': {
|
2015-04-08 18:08:50 +02:00
|
|
|
'type': 'objectid',
|
2015-04-24 12:43:25 +02:00
|
|
|
'data_relation': {
|
|
|
|
'resource': 'nodes',
|
|
|
|
'field': '_id',
|
|
|
|
'embeddable': True
|
|
|
|
},
|
2015-03-10 11:38:57 +01:00
|
|
|
},
|
2015-04-10 13:08:45 -03:00
|
|
|
'user': {
|
2015-04-13 01:21:57 +02:00
|
|
|
'type': 'objectid',
|
2015-04-10 13:08:45 -03:00
|
|
|
'required': True,
|
|
|
|
},
|
2015-03-27 15:42:28 +01:00
|
|
|
'node_type': {
|
2015-04-08 18:08:50 +02:00
|
|
|
'type': 'objectid',
|
2015-03-11 16:03:19 +01:00
|
|
|
'required': True,
|
2015-04-24 12:43:25 +02:00
|
|
|
'data_relation': {
|
|
|
|
'resource': 'node_types',
|
|
|
|
'field': '_id',
|
|
|
|
'embeddable': True
|
|
|
|
},
|
2015-03-10 11:38:57 +01:00
|
|
|
},
|
2015-03-27 15:42:28 +01:00
|
|
|
'properties': {
|
2015-03-11 16:03:19 +01:00
|
|
|
'type' : 'dict',
|
|
|
|
'valid_properties' : True,
|
|
|
|
'required': True,
|
2015-03-27 15:42:28 +01:00
|
|
|
},
|
2015-03-11 16:03:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
node_types_schema = {
|
|
|
|
'name': {
|
|
|
|
'type': 'string',
|
|
|
|
'minlength': 1,
|
|
|
|
'maxlength': 128,
|
|
|
|
'required': True,
|
|
|
|
},
|
2015-03-27 15:42:28 +01:00
|
|
|
'description': {
|
|
|
|
'type': 'string',
|
|
|
|
'maxlength': 256,
|
|
|
|
},
|
2015-03-11 16:03:19 +01:00
|
|
|
'dyn_schema': {
|
|
|
|
'type': 'dict',
|
|
|
|
'required': True,
|
2015-04-13 15:08:44 -03:00
|
|
|
},
|
|
|
|
'form_schema': {
|
|
|
|
'type': 'dict',
|
|
|
|
'required': True,
|
|
|
|
},
|
|
|
|
'parent': {
|
|
|
|
'type': 'dict',
|
|
|
|
'required': True,
|
2015-03-11 16:03:19 +01:00
|
|
|
}
|
2015-03-10 11:38:57 +01:00
|
|
|
}
|
|
|
|
|
2015-04-09 16:36:32 -03:00
|
|
|
tokens_schema = {
|
2015-04-09 19:06:10 -03:00
|
|
|
'user': {
|
|
|
|
'type': 'objectid',
|
2015-03-14 15:08:36 +01:00
|
|
|
'required': True,
|
|
|
|
},
|
|
|
|
'token': {
|
|
|
|
'type': 'string',
|
2015-04-08 11:47:19 -03:00
|
|
|
'required': True,
|
2015-04-09 16:36:32 -03:00
|
|
|
},
|
|
|
|
'expire_time': {
|
|
|
|
'type': 'datetime',
|
|
|
|
'required': True,
|
|
|
|
},
|
|
|
|
}
|
2015-03-14 15:08:36 +01:00
|
|
|
|
2015-04-20 08:56:22 -03:00
|
|
|
files_schema = {
|
|
|
|
'name': {
|
|
|
|
'type': 'string',
|
|
|
|
'required': True,
|
|
|
|
},
|
|
|
|
'description': {
|
|
|
|
'type': 'string',
|
|
|
|
'required': True,
|
|
|
|
},
|
|
|
|
'user': {
|
|
|
|
'type': 'objectid',
|
|
|
|
'required': True,
|
|
|
|
},
|
|
|
|
'contentType': {
|
|
|
|
'type': 'string',
|
|
|
|
'required': True,
|
|
|
|
},
|
|
|
|
'length': {
|
|
|
|
'type': 'integer',
|
|
|
|
'required': True,
|
|
|
|
},
|
|
|
|
'uploadDate': {
|
|
|
|
'type': 'datetime',
|
|
|
|
'required': True,
|
|
|
|
},
|
|
|
|
'md5': {
|
|
|
|
'type': 'string',
|
|
|
|
'required': True,
|
|
|
|
},
|
|
|
|
'filename': {
|
|
|
|
'type': 'string',
|
|
|
|
'required': True,
|
|
|
|
},
|
2015-04-21 17:26:41 -03:00
|
|
|
'backend': {
|
|
|
|
'type': 'string',
|
|
|
|
'required': True,
|
2015-04-23 16:03:34 -03:00
|
|
|
'allowed': ["fs.files", "attract-web", "attract"]
|
2015-04-21 17:26:41 -03:00
|
|
|
},
|
2015-04-20 08:56:22 -03:00
|
|
|
#'thumbnail': {
|
|
|
|
# 'type': 'string',
|
|
|
|
#},
|
|
|
|
#'preview': {
|
|
|
|
# 'type': 'string',
|
|
|
|
#},
|
|
|
|
#'binary_data': {
|
|
|
|
# 'type': 'media',
|
|
|
|
#},
|
|
|
|
'path': {
|
|
|
|
'type': 'string',
|
|
|
|
'required': True,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-21 17:26:41 -03:00
|
|
|
binary_files_schema = {
|
|
|
|
'data': {
|
|
|
|
'type': 'media',
|
|
|
|
'required': True,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-10 11:38:57 +01:00
|
|
|
nodes = {
|
|
|
|
'schema': nodes_schema
|
|
|
|
}
|
|
|
|
|
2015-03-11 16:03:19 +01:00
|
|
|
node_types = {
|
|
|
|
'resource_methods': ['GET', 'POST'],
|
2015-03-14 15:08:36 +01:00
|
|
|
'schema': node_types_schema,
|
2015-03-11 16:03:19 +01:00
|
|
|
}
|
2015-03-10 11:38:57 +01:00
|
|
|
|
2015-03-11 16:03:19 +01:00
|
|
|
users = {
|
|
|
|
'item_title': 'user',
|
2015-03-10 11:38:57 +01:00
|
|
|
|
|
|
|
# We choose to override global cache-control directives for this resource.
|
|
|
|
'cache_control': 'max-age=10,must-revalidate',
|
|
|
|
'cache_expires': 10,
|
|
|
|
|
|
|
|
# most global settings can be overridden at resource level
|
|
|
|
'resource_methods': ['GET', 'POST'],
|
|
|
|
|
2015-03-11 16:03:19 +01:00
|
|
|
'public_methods': ['GET', 'POST'],
|
|
|
|
# 'public_item_methods': ['GET'],
|
|
|
|
|
|
|
|
'schema': users_schema
|
2015-03-10 11:38:57 +01:00
|
|
|
}
|
|
|
|
|
2015-04-09 16:36:32 -03:00
|
|
|
tokens = {
|
2015-04-13 01:21:57 +02:00
|
|
|
'resource_methods': ['GET', 'POST'],
|
2015-03-14 15:08:36 +01:00
|
|
|
|
|
|
|
# Allow 'token' to be returned with POST responses
|
2015-04-08 11:47:19 -03:00
|
|
|
#'extra_response_fields': ['token'],
|
2015-03-14 15:08:36 +01:00
|
|
|
|
|
|
|
'schema' : tokens_schema
|
2015-04-09 16:36:32 -03:00
|
|
|
}
|
2015-03-10 11:38:57 +01:00
|
|
|
|
2015-04-20 08:56:22 -03:00
|
|
|
files = {
|
|
|
|
'resource_methods': ['GET', 'POST'],
|
|
|
|
'schema': files_schema,
|
|
|
|
}
|
|
|
|
|
2015-04-21 17:26:41 -03:00
|
|
|
binary_files = {
|
|
|
|
'resource_methods': ['GET', 'POST'],
|
|
|
|
'schema': binary_files_schema,
|
|
|
|
}
|
|
|
|
|
2015-03-10 11:38:57 +01:00
|
|
|
DOMAIN = {
|
2015-03-11 16:03:19 +01:00
|
|
|
'users': users,
|
2015-04-08 11:47:19 -03:00
|
|
|
'nodes': nodes,
|
2015-03-11 16:03:19 +01:00
|
|
|
'node_types': node_types,
|
2015-04-09 16:36:32 -03:00
|
|
|
'tokens': tokens,
|
2015-04-20 08:56:22 -03:00
|
|
|
'files': files,
|
2015-04-21 17:26:41 -03:00
|
|
|
'binary_files': binary_files,
|
2015-03-10 11:38:57 +01:00
|
|
|
}
|
|
|
|
|
2015-03-12 15:05:10 +01:00
|
|
|
try:
|
|
|
|
os.environ['TEST_ATTRACT']
|
|
|
|
MONGO_DBNAME = 'attract_test'
|
|
|
|
except:
|
|
|
|
pass
|