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-03-27 15:42:28 +01:00
|
|
|
ITEM_METHODS = ['GET', 'PUT', 'DELETE']
|
2015-03-10 11:38:57 +01:00
|
|
|
|
|
|
|
|
2015-03-11 16:03:19 +01:00
|
|
|
users_schema = {
|
2015-03-10 11:38:57 +01:00
|
|
|
'firstname': {
|
|
|
|
'type': 'string',
|
|
|
|
'minlength': 1,
|
2015-04-09 19:06:10 -03:00
|
|
|
'maxlength': 60,
|
2015-03-10 11:38:57 +01:00
|
|
|
},
|
|
|
|
'lastname': {
|
|
|
|
'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': {
|
|
|
|
'type': 'media'
|
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-13 15:08:44 -03:00
|
|
|
#'default': '',
|
2015-03-27 15:42:28 +01:00
|
|
|
#'data_relation': {
|
|
|
|
# 'resource': 'nodes',
|
|
|
|
# 'field': '_id',
|
|
|
|
#},
|
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-03-27 15:42:28 +01:00
|
|
|
#'data_relation': {
|
|
|
|
# 'resource': 'node_types',
|
|
|
|
# 'field': '_id',
|
|
|
|
#},
|
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-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
|
|
|
|
|
|
|
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-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
|