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-09-24 15:45:57 +02:00
|
|
|
PAGINATION_LIMIT = 25
|
2015-03-10 11:38:57 +01:00
|
|
|
|
2016-01-25 16:32:50 +01:00
|
|
|
_file_embedded_schema = {
|
|
|
|
'type': 'objectid',
|
|
|
|
'data_relation': {
|
|
|
|
'resource': 'files',
|
|
|
|
'field': '_id',
|
|
|
|
'embeddable': True
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-05 23:22:57 +01:00
|
|
|
_required_user_embedded_schema = {
|
|
|
|
'type': 'objectid',
|
|
|
|
'required': True,
|
|
|
|
'data_relation': {
|
|
|
|
'resource': 'users',
|
|
|
|
'field': '_id',
|
|
|
|
'embeddable': True
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2016-03-04 18:53:59 +01:00
|
|
|
_activity_object_type = {
|
|
|
|
'type': 'string',
|
|
|
|
'required': True,
|
|
|
|
'allowed': [
|
|
|
|
'project',
|
|
|
|
'user',
|
|
|
|
'node'
|
|
|
|
],
|
|
|
|
}
|
|
|
|
|
2015-03-11 16:03:19 +01:00
|
|
|
users_schema = {
|
2015-10-13 19:40:25 +02:00
|
|
|
'full_name': {
|
2015-03-10 11:38:57 +01:00
|
|
|
'type': 'string',
|
2015-11-04 16:22:47 +01:00
|
|
|
'minlength': 3,
|
2015-10-13 19:40:25 +02:00
|
|
|
'maxlength': 128,
|
2015-11-05 00:23:48 +01:00
|
|
|
'required': True,
|
2015-04-09 19:06:10 -03:00
|
|
|
},
|
2015-08-31 17:45:29 +02:00
|
|
|
'username': {
|
|
|
|
'type': 'string',
|
2015-11-04 16:22:47 +01:00
|
|
|
'minlength': 3,
|
|
|
|
'maxlength': 128,
|
2015-08-31 17:45:29 +02:00
|
|
|
'required': True,
|
2015-11-04 16:22:47 +01:00
|
|
|
'unique': True,
|
2015-08-31 17:45:29 +02:00
|
|
|
},
|
2015-04-09 19:06:10 -03:00
|
|
|
'email': {
|
|
|
|
'type': 'string',
|
2015-11-04 16:22:47 +01:00
|
|
|
'minlength': 5,
|
2015-04-09 19:06:10 -03:00
|
|
|
'maxlength': 60,
|
2015-03-10 11:38:57 +01:00
|
|
|
},
|
2015-10-13 19:40:25 +02:00
|
|
|
'roles': {
|
2015-03-27 15:42:28 +01:00
|
|
|
'type': 'list',
|
2016-02-10 16:13:07 +01:00
|
|
|
'allowed': ["admin", "subscriber", "demo"],
|
2015-05-18 11:42:17 -03:00
|
|
|
},
|
|
|
|
'groups': {
|
|
|
|
'type': 'list',
|
|
|
|
'default': [],
|
2015-05-21 12:04:46 -03:00
|
|
|
'schema': {
|
2015-05-18 11:42:17 -03:00
|
|
|
'type': 'objectid',
|
|
|
|
'data_relation': {
|
|
|
|
'resource': 'groups',
|
|
|
|
'field': '_id',
|
|
|
|
'embeddable': True
|
|
|
|
}
|
|
|
|
}
|
2015-10-13 19:40:25 +02:00
|
|
|
},
|
|
|
|
'auth': {
|
|
|
|
# Storage of authentication credentials (one will be able to auth with
|
|
|
|
# multiple providers on the same account)
|
|
|
|
'type': 'list',
|
|
|
|
'required': True,
|
|
|
|
'schema': {
|
|
|
|
'type': 'dict',
|
|
|
|
'schema': {
|
|
|
|
'provider': {
|
|
|
|
'type': 'string',
|
2016-04-26 12:33:48 +02:00
|
|
|
'allowed': ["blender-id", "local"],
|
2015-10-13 19:40:25 +02:00
|
|
|
},
|
2016-04-26 12:33:48 +02:00
|
|
|
'user_id': {
|
2015-10-13 19:40:25 +02:00
|
|
|
'type': 'string'
|
|
|
|
},
|
2016-04-26 12:33:48 +02:00
|
|
|
# A token is considered a "password" in case the provider is
|
|
|
|
# "local".
|
2015-10-13 19:40:25 +02:00
|
|
|
'token': {
|
|
|
|
'type': 'string'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-11-12 00:34:32 +01:00
|
|
|
},
|
|
|
|
'settings': {
|
|
|
|
'type': 'dict',
|
|
|
|
'schema': {
|
|
|
|
'email_communications': {
|
|
|
|
'type': 'integer',
|
|
|
|
'allowed': [0, 1]
|
|
|
|
}
|
|
|
|
}
|
2015-04-13 01:21:57 +02:00
|
|
|
}
|
2015-03-10 11:38:57 +01:00
|
|
|
}
|
|
|
|
|
2015-08-31 17:45:29 +02:00
|
|
|
organizations_schema = {
|
|
|
|
'name': {
|
|
|
|
'type': 'string',
|
|
|
|
'minlength': 1,
|
|
|
|
'maxlength': 128,
|
|
|
|
'required': True
|
|
|
|
},
|
2015-10-05 19:57:37 +02:00
|
|
|
'email': {
|
|
|
|
'type': 'string'
|
|
|
|
},
|
2015-08-31 17:45:29 +02:00
|
|
|
'url': {
|
|
|
|
'type': 'string',
|
|
|
|
'minlength': 1,
|
|
|
|
'maxlength': 128,
|
|
|
|
'required': True
|
|
|
|
},
|
|
|
|
'description': {
|
|
|
|
'type': 'string',
|
|
|
|
'maxlength': 256,
|
|
|
|
},
|
|
|
|
'website': {
|
|
|
|
'type': 'string',
|
|
|
|
'maxlength': 256,
|
|
|
|
},
|
|
|
|
'location': {
|
|
|
|
'type': 'string',
|
|
|
|
'maxlength': 256,
|
|
|
|
},
|
|
|
|
'picture': {
|
|
|
|
'type': 'objectid',
|
|
|
|
'nullable': True,
|
|
|
|
'data_relation': {
|
|
|
|
'resource': 'files',
|
|
|
|
'field': '_id',
|
|
|
|
'embeddable': True
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'users': {
|
|
|
|
'type': 'list',
|
|
|
|
'default': [],
|
|
|
|
'schema': {
|
|
|
|
'type': 'objectid',
|
|
|
|
'data_relation': {
|
|
|
|
'resource': 'users',
|
|
|
|
'field': '_id',
|
|
|
|
'embeddable': True
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'teams': {
|
|
|
|
'type': 'list',
|
|
|
|
'default': [],
|
|
|
|
'schema': {
|
|
|
|
'type': 'dict',
|
|
|
|
'schema': {
|
|
|
|
# Team name
|
|
|
|
'name': {
|
|
|
|
'type': 'string',
|
|
|
|
'minlength': 1,
|
|
|
|
'maxlength': 128,
|
|
|
|
'required': True
|
|
|
|
},
|
|
|
|
# List of user ids for the team
|
|
|
|
'users': {
|
|
|
|
'type': 'list',
|
|
|
|
'default': [],
|
|
|
|
'schema': {
|
|
|
|
'type': 'objectid',
|
|
|
|
'data_relation': {
|
|
|
|
'resource': 'users',
|
|
|
|
'field': '_id',
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
# List of groups assigned to the team (this will automatically
|
|
|
|
# update the groups property of each user in the team)
|
|
|
|
'groups': {
|
|
|
|
'type': 'list',
|
|
|
|
'default': [],
|
|
|
|
'schema': {
|
|
|
|
'type': 'objectid',
|
|
|
|
'data_relation': {
|
|
|
|
'resource': 'groups',
|
|
|
|
'field': '_id',
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-11 22:20:18 +02:00
|
|
|
permissions_embedded_schema = {
|
|
|
|
'groups': {
|
|
|
|
'type': 'list',
|
|
|
|
'schema': {
|
|
|
|
'type': 'dict',
|
|
|
|
'schema': {
|
|
|
|
'group': {
|
|
|
|
'type': 'objectid',
|
|
|
|
'required': True,
|
|
|
|
'data_relation': {
|
|
|
|
'resource': 'groups',
|
|
|
|
'field': '_id',
|
|
|
|
'embeddable': True
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'methods': {
|
|
|
|
'type': 'list',
|
|
|
|
'required': True,
|
|
|
|
'allowed': ['GET', 'PUT', 'POST', 'DELETE']
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'users': {
|
|
|
|
'type': 'list',
|
|
|
|
'schema': {
|
|
|
|
'type': 'dict',
|
|
|
|
'schema': {
|
|
|
|
'user' : {
|
|
|
|
'type': 'objectid',
|
|
|
|
'required': True,
|
|
|
|
},
|
|
|
|
'methods': {
|
|
|
|
'type': 'list',
|
|
|
|
'required': True,
|
|
|
|
'allowed': ['GET', 'PUT', 'POST', 'DELETE']
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'world': {
|
|
|
|
'type': 'list',
|
|
|
|
#'required': True,
|
|
|
|
'allowed': ['GET',]
|
|
|
|
},
|
|
|
|
'is_free': {
|
|
|
|
'type': 'boolean',
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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-04-13 01:21:57 +02:00
|
|
|
'picture': {
|
2015-04-16 15:02:32 -03:00
|
|
|
'type': 'objectid',
|
2015-04-24 16:15:47 +02:00
|
|
|
'data_relation': {
|
|
|
|
'resource': 'files',
|
|
|
|
'field': '_id',
|
|
|
|
'embeddable': True
|
|
|
|
},
|
2015-03-10 11:38:57 +01:00
|
|
|
},
|
2015-03-27 15:42:28 +01:00
|
|
|
'order': {
|
|
|
|
'type': 'integer',
|
|
|
|
'minlength': 0,
|
|
|
|
},
|
2015-09-08 15:06:45 +02:00
|
|
|
'revision': {
|
|
|
|
'type': 'integer',
|
|
|
|
},
|
2015-03-10 11:38:57 +01:00
|
|
|
'parent': {
|
2015-04-08 18:08:50 +02:00
|
|
|
'type': 'objectid',
|
2015-10-28 20:34:14 +01:00
|
|
|
'data_relation': {
|
|
|
|
'resource': 'nodes',
|
|
|
|
'field': '_id',
|
|
|
|
'embeddable': True
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'project': {
|
|
|
|
'type': 'objectid',
|
2015-04-24 12:43:25 +02:00
|
|
|
'data_relation': {
|
2016-01-25 16:32:50 +01:00
|
|
|
'resource': 'projects',
|
2015-04-24 12:43:25 +02:00
|
|
|
'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-05-01 11:32:42 -03:00
|
|
|
'data_relation': {
|
|
|
|
'resource': 'users',
|
|
|
|
'field': '_id',
|
|
|
|
'embeddable': True
|
|
|
|
},
|
2015-04-10 13:08:45 -03:00
|
|
|
},
|
2015-03-27 15:42:28 +01:00
|
|
|
'node_type': {
|
2016-01-25 16:32:50 +01:00
|
|
|
'type': 'string',
|
|
|
|
'required': True
|
2015-03-10 11:38:57 +01:00
|
|
|
},
|
2015-10-11 22:20:18 +02:00
|
|
|
'properties': {
|
|
|
|
'type' : 'dict',
|
|
|
|
'valid_properties' : True,
|
|
|
|
'required': True,
|
2015-03-27 15:42:28 +01:00
|
|
|
},
|
2015-10-11 22:20:18 +02:00
|
|
|
'permissions': {
|
|
|
|
'type': 'dict',
|
|
|
|
'schema': permissions_embedded_schema
|
|
|
|
}
|
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-10-11 22:20:18 +02:00
|
|
|
},
|
|
|
|
'permissions': {
|
|
|
|
'type': 'dict',
|
|
|
|
'required': True,
|
|
|
|
'schema': permissions_embedded_schema
|
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,
|
|
|
|
},
|
2016-04-15 16:27:24 +02:00
|
|
|
'is_subclient_token': {
|
|
|
|
'type': 'boolean',
|
|
|
|
'required': False,
|
|
|
|
}
|
2015-04-09 16:36:32 -03:00
|
|
|
}
|
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',
|
|
|
|
},
|
2015-09-11 15:16:10 +02:00
|
|
|
'content_type': { # MIME type image/png video/mp4
|
2015-09-08 15:06:45 +02:00
|
|
|
'type': 'string',
|
|
|
|
'required': True,
|
|
|
|
},
|
|
|
|
# Duration in seconds, only if it's a video
|
|
|
|
'duration': {
|
|
|
|
'type': 'integer',
|
|
|
|
},
|
|
|
|
'size': { # xs, s, b, 720p, 2K
|
2015-05-08 11:28:58 -03:00
|
|
|
'type': 'string'
|
|
|
|
},
|
2015-09-08 15:06:45 +02:00
|
|
|
'format': { # human readable format, like mp4, HLS, webm, mov
|
2015-05-09 12:26:49 -03:00
|
|
|
'type': 'string'
|
|
|
|
},
|
2015-09-24 15:45:57 +02:00
|
|
|
'width': { # valid for images and video content_type
|
2015-05-09 12:26:49 -03:00
|
|
|
'type': 'integer'
|
|
|
|
},
|
|
|
|
'height': {
|
|
|
|
'type': 'integer'
|
|
|
|
},
|
2015-04-20 08:56:22 -03:00
|
|
|
'user': {
|
|
|
|
'type': 'objectid',
|
|
|
|
'required': True,
|
|
|
|
},
|
2015-09-08 15:06:45 +02:00
|
|
|
'length': { # Size in bytes
|
2015-04-20 08:56:22 -03:00
|
|
|
'type': 'integer',
|
|
|
|
'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,
|
2016-04-01 13:03:27 +02:00
|
|
|
'allowed': ["attract-web", "pillar", "cdnsun", "gcs", "unittest"]
|
2015-04-24 16:15:47 +02:00
|
|
|
},
|
2015-11-05 18:47:36 +01:00
|
|
|
'file_path': {
|
2015-04-20 08:56:22 -03:00
|
|
|
'type': 'string',
|
2015-09-24 15:45:57 +02:00
|
|
|
#'required': True,
|
2015-05-08 11:28:58 -03:00
|
|
|
'unique': True,
|
|
|
|
},
|
2016-03-21 15:17:09 +01:00
|
|
|
'link': {
|
|
|
|
'type': 'string',
|
|
|
|
},
|
|
|
|
'link_expires': {
|
|
|
|
'type': 'datetime',
|
|
|
|
},
|
2015-11-04 12:57:36 +01:00
|
|
|
'project': {
|
|
|
|
# The project node the files belongs to (does not matter if it is
|
|
|
|
# attached to an asset or something else). We use the project id as
|
|
|
|
# top level filtering, folder or bucket name. Later on we will be able
|
|
|
|
# to join permissions from the project and verify user access.
|
|
|
|
'type': 'objectid',
|
|
|
|
'data_relation': {
|
2016-01-27 17:50:39 +01:00
|
|
|
'resource': 'projects',
|
2015-11-04 12:57:36 +01:00
|
|
|
'field': '_id',
|
|
|
|
'embeddable': True
|
|
|
|
},
|
|
|
|
},
|
2015-11-25 16:16:09 +01:00
|
|
|
'variations': { # File variations (used to be children, see above)
|
|
|
|
'type': 'list',
|
|
|
|
'schema': {
|
|
|
|
'type': 'dict',
|
|
|
|
'schema': {
|
2016-02-26 16:17:38 +01:00
|
|
|
'is_public': { # If True, the link will not be hashed or signed
|
|
|
|
'type': 'boolean'
|
|
|
|
},
|
2015-11-25 16:16:09 +01:00
|
|
|
'content_type': { # MIME type image/png video/mp4
|
|
|
|
'type': 'string',
|
|
|
|
'required': True,
|
|
|
|
},
|
|
|
|
'duration': {
|
|
|
|
'type': 'integer',
|
|
|
|
},
|
|
|
|
'size': { # xs, s, b, 720p, 2K
|
|
|
|
'type': 'string'
|
|
|
|
},
|
|
|
|
'format': { # human readable format, like mp4, HLS, webm, mov
|
|
|
|
'type': 'string'
|
|
|
|
},
|
|
|
|
'width': { # valid for images and video content_type
|
|
|
|
'type': 'integer'
|
|
|
|
},
|
|
|
|
'height': {
|
|
|
|
'type': 'integer'
|
|
|
|
},
|
|
|
|
'length': { # Size in bytes
|
|
|
|
'type': 'integer',
|
|
|
|
'required': True,
|
|
|
|
},
|
|
|
|
'md5': {
|
|
|
|
'type': 'string',
|
|
|
|
'required': True,
|
|
|
|
},
|
|
|
|
'file_path': {
|
|
|
|
'type': 'string',
|
|
|
|
},
|
2016-03-21 15:17:09 +01:00
|
|
|
'link': {
|
|
|
|
'type': 'string',
|
|
|
|
}
|
2015-11-25 16:16:09 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2016-02-22 16:48:53 +01:00
|
|
|
'processing': {
|
|
|
|
'type': 'dict',
|
2015-05-08 11:28:58 -03:00
|
|
|
'schema': {
|
2016-02-22 16:48:53 +01:00
|
|
|
'job_id': {
|
|
|
|
'type': 'string' # can be int, depending on the backend
|
|
|
|
},
|
|
|
|
'backend': {
|
|
|
|
'type': 'string',
|
|
|
|
'allowed': ["zencoder", "local"]
|
|
|
|
},
|
|
|
|
'status': {
|
|
|
|
'type': 'string',
|
|
|
|
'allowed': ["pending", "waiting", "processing", "finished",
|
|
|
|
"failed", "cancelled"]
|
|
|
|
},
|
2015-05-08 11:28:58 -03:00
|
|
|
}
|
2015-04-20 08:56:22 -03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-18 11:42:17 -03:00
|
|
|
groups_schema = {
|
|
|
|
'name': {
|
|
|
|
'type': 'string',
|
|
|
|
'required': True
|
2015-04-21 17:26:41 -03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-25 16:32:50 +01:00
|
|
|
projects_schema = {
|
|
|
|
'name': {
|
|
|
|
'type': 'string',
|
|
|
|
'minlength': 1,
|
|
|
|
'maxlength': 128,
|
|
|
|
'required': True,
|
|
|
|
},
|
|
|
|
'description': {
|
|
|
|
'type': 'string',
|
|
|
|
},
|
|
|
|
# Short summary for the project
|
|
|
|
'summary': {
|
|
|
|
'type': 'string',
|
|
|
|
'maxlength': 128
|
|
|
|
},
|
|
|
|
# Logo
|
|
|
|
'picture_square': _file_embedded_schema,
|
|
|
|
# Header
|
|
|
|
'picture_header': _file_embedded_schema,
|
|
|
|
'user': {
|
|
|
|
'type': 'objectid',
|
|
|
|
'required': True,
|
|
|
|
'data_relation': {
|
|
|
|
'resource': 'users',
|
|
|
|
'field': '_id',
|
|
|
|
'embeddable': True
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'category': {
|
|
|
|
'type': 'string',
|
|
|
|
'allowed': [
|
|
|
|
'training',
|
|
|
|
'film',
|
|
|
|
'assets',
|
|
|
|
'software',
|
|
|
|
'game'
|
|
|
|
],
|
|
|
|
'required': True,
|
|
|
|
},
|
|
|
|
'is_private': {
|
|
|
|
'type': 'boolean'
|
|
|
|
},
|
|
|
|
'url': {
|
|
|
|
'type': 'string'
|
|
|
|
},
|
|
|
|
'organization': {
|
|
|
|
'type': 'objectid',
|
|
|
|
'nullable': True,
|
|
|
|
'data_relation': {
|
|
|
|
'resource': 'organizations',
|
|
|
|
'field': '_id',
|
|
|
|
'embeddable': True
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'status': {
|
|
|
|
'type': 'string',
|
|
|
|
'allowed': [
|
|
|
|
'published',
|
|
|
|
'pending',
|
|
|
|
'deleted'
|
|
|
|
],
|
|
|
|
},
|
|
|
|
# Latest nodes being edited
|
|
|
|
'nodes_latest': {
|
|
|
|
'type': 'list',
|
|
|
|
'schema': {
|
|
|
|
'type': 'objectid',
|
|
|
|
}
|
|
|
|
},
|
|
|
|
# Featured nodes, manually added
|
|
|
|
'nodes_featured': {
|
|
|
|
'type': 'list',
|
|
|
|
'schema': {
|
|
|
|
'type': 'objectid',
|
|
|
|
}
|
|
|
|
},
|
|
|
|
# Latest blog posts, manually added
|
|
|
|
'nodes_blog': {
|
|
|
|
'type': 'list',
|
|
|
|
'schema': {
|
|
|
|
'type': 'objectid',
|
|
|
|
}
|
|
|
|
},
|
|
|
|
# Where Node type schemas for every projects are defined
|
|
|
|
'node_types': {
|
|
|
|
'type': 'list',
|
|
|
|
'schema': {
|
|
|
|
'type': 'dict',
|
|
|
|
'schema': {
|
|
|
|
# URL is the way we identify a node_type when calling it via
|
|
|
|
# the helper methods in the Project API.
|
|
|
|
'url': {'type': 'string'},
|
|
|
|
'name': {'type': 'string'},
|
|
|
|
'description': {'type': 'string'},
|
|
|
|
# Allowed parents for the node_type
|
|
|
|
'parent': {
|
|
|
|
'type': 'list',
|
|
|
|
'schema': {
|
|
|
|
'type': 'string'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'dyn_schema': {
|
|
|
|
'type': 'dict',
|
|
|
|
'allow_unknown': True
|
|
|
|
},
|
|
|
|
'form_schema': {
|
|
|
|
'type': 'dict',
|
|
|
|
'allow_unknown': True
|
|
|
|
},
|
|
|
|
'permissions': {
|
|
|
|
'type': 'dict',
|
|
|
|
'schema': permissions_embedded_schema
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'permissions': {
|
|
|
|
'type': 'dict',
|
|
|
|
'schema': permissions_embedded_schema
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-04 18:53:59 +01:00
|
|
|
activities_subscriptions_schema = {
|
2016-03-05 23:22:57 +01:00
|
|
|
'user': _required_user_embedded_schema,
|
2016-03-04 18:53:59 +01:00
|
|
|
'context_object_type': _activity_object_type,
|
|
|
|
'context_object': {
|
|
|
|
'type': 'objectid',
|
|
|
|
'required': True
|
|
|
|
},
|
|
|
|
'notifications': {
|
|
|
|
'type': 'dict',
|
|
|
|
'schema': {
|
|
|
|
'email': {
|
|
|
|
'type': 'boolean',
|
|
|
|
},
|
|
|
|
'web': {
|
|
|
|
'type': 'boolean',
|
2016-03-05 23:22:57 +01:00
|
|
|
'default': True
|
2016-03-04 18:53:59 +01:00
|
|
|
},
|
|
|
|
}
|
2016-03-05 23:22:57 +01:00
|
|
|
},
|
|
|
|
'is_subscribed': {
|
|
|
|
'type': 'boolean',
|
|
|
|
'default': True
|
2016-03-04 18:53:59 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
activities_schema = {
|
2016-03-05 23:22:57 +01:00
|
|
|
'actor_user': _required_user_embedded_schema,
|
2016-03-04 18:53:59 +01:00
|
|
|
'verb': {
|
|
|
|
'type': 'string',
|
|
|
|
'required': True
|
|
|
|
},
|
|
|
|
'object_type': _activity_object_type,
|
|
|
|
'object': {
|
|
|
|
'type': 'objectid',
|
|
|
|
'required': True
|
|
|
|
},
|
|
|
|
'context_object_type': _activity_object_type,
|
|
|
|
'context_object': {
|
|
|
|
'type': 'objectid',
|
|
|
|
'required': True
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
notifications_schema = {
|
2016-03-05 23:22:57 +01:00
|
|
|
'user': _required_user_embedded_schema,
|
2016-03-04 18:53:59 +01:00
|
|
|
'activity': {
|
|
|
|
'type': 'objectid',
|
2016-03-05 23:22:57 +01:00
|
|
|
'required': True,
|
2016-03-04 18:53:59 +01:00
|
|
|
},
|
|
|
|
'is_read': {
|
|
|
|
'type': 'boolean',
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-03-10 11:38:57 +01:00
|
|
|
nodes = {
|
2015-10-11 22:20:18 +02:00
|
|
|
'schema': nodes_schema,
|
|
|
|
'public_methods': ['GET'],
|
|
|
|
'public_item_methods': ['GET']
|
2015-03-10 11:38:57 +01:00
|
|
|
}
|
|
|
|
|
2015-03-11 16:03:19 +01:00
|
|
|
node_types = {
|
|
|
|
'resource_methods': ['GET', 'POST'],
|
2015-10-11 22:20:18 +02:00
|
|
|
'public_methods': ['GET'],
|
|
|
|
'public_item_methods': ['GET'],
|
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,
|
|
|
|
|
2016-04-26 11:04:28 +02:00
|
|
|
'resource_methods': ['GET'],
|
|
|
|
'item_methods': ['GET', 'PUT'],
|
2016-04-26 10:45:54 +02:00
|
|
|
'public_methods': [],
|
|
|
|
|
|
|
|
# By default don't include the 'auth' field. It can still be obtained
|
|
|
|
# using projections, though, so we block that in hooks.
|
|
|
|
'datasource': {'projection': {u'auth': 0}},
|
2015-03-11 16:03:19 +01:00
|
|
|
|
|
|
|
'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'],
|
2015-10-11 22:20:18 +02:00
|
|
|
'public_methods': ['GET'],
|
|
|
|
'public_item_methods': ['GET'],
|
|
|
|
'schema': files_schema
|
2015-04-20 08:56:22 -03:00
|
|
|
}
|
|
|
|
|
2015-05-18 11:42:17 -03:00
|
|
|
groups = {
|
|
|
|
'resource_methods': ['GET', 'POST'],
|
2015-10-11 23:30:41 +02:00
|
|
|
'public_methods': ['GET'],
|
|
|
|
'public_item_methods': ['GET'],
|
2015-05-18 11:42:17 -03:00
|
|
|
'schema': groups_schema,
|
|
|
|
}
|
|
|
|
|
2015-08-31 17:45:29 +02:00
|
|
|
organizations = {
|
|
|
|
'schema': organizations_schema,
|
2015-10-11 23:30:41 +02:00
|
|
|
'public_item_methods': ['GET'],
|
|
|
|
'public_methods': ['GET']
|
2015-08-31 17:45:29 +02:00
|
|
|
}
|
|
|
|
|
2016-01-25 16:32:50 +01:00
|
|
|
projects = {
|
|
|
|
'schema': projects_schema,
|
|
|
|
'public_item_methods': ['GET'],
|
2016-04-25 16:13:15 +02:00
|
|
|
'public_methods': ['GET'],
|
|
|
|
'soft_delete': True,
|
2016-01-25 16:32:50 +01:00
|
|
|
}
|
|
|
|
|
2016-03-04 18:53:59 +01:00
|
|
|
activities = {
|
|
|
|
'schema': activities_schema,
|
|
|
|
}
|
|
|
|
|
|
|
|
activities_subscriptions = {
|
|
|
|
'schema': activities_subscriptions_schema,
|
|
|
|
}
|
|
|
|
|
|
|
|
notifications = {
|
2016-03-05 23:22:57 +01:00
|
|
|
'schema': notifications_schema,
|
2016-03-04 18:53:59 +01: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-04-20 08:56:22 -03:00
|
|
|
'files': files,
|
2015-08-31 17:45:29 +02:00
|
|
|
'groups': groups,
|
2016-01-25 16:32:50 +01:00
|
|
|
'organizations': organizations,
|
2016-03-04 18:53:59 +01:00
|
|
|
'projects': projects,
|
|
|
|
'activities': activities,
|
|
|
|
'activities-subscriptions': activities_subscriptions,
|
|
|
|
'notifications': notifications
|
2015-03-10 11:38:57 +01:00
|
|
|
}
|
|
|
|
|
2015-08-31 17:45:29 +02:00
|
|
|
|
2015-10-11 22:20:18 +02:00
|
|
|
MONGO_HOST = os.environ.get('MONGO_HOST', 'localhost')
|
|
|
|
MONGO_PORT = os.environ.get('MONGO_PORT', 27017)
|
2016-02-25 15:01:17 +01:00
|
|
|
MONGO_DBNAME = os.environ.get('MONGO_DBNAME', 'eve')
|
2015-10-16 17:49:15 +02:00
|
|
|
CACHE_EXPIRES = 60
|
|
|
|
HATEOAS = False
|
2016-04-25 15:21:17 +02:00
|
|
|
UPSET_ON_PUT = False # do not create new document on PUT of non-existant URL.
|