pillar/attract/settings.py

245 lines
4.7 KiB
Python
Raw Normal View History

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
# 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,
'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,
'maxlength': 60,
},
'email': {
'type': 'string',
'minlength': 1,
'maxlength': 60,
2015-03-10 11:38:57 +01:00
},
'role': {
'type': 'list',
'allowed': ["admin"],
2015-03-11 16:03:19 +01:00
'required': True,
}
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',
'minlength': 0,
2015-03-11 16:03:19 +01:00
'maxlength': 128,
},
'picture': {
2015-04-16 15:02:32 -03:00
'type': 'objectid',
'nullable': True,
2015-03-10 11:38:57 +01:00
},
'order': {
'type': 'integer',
'minlength': 0,
},
2015-03-10 11:38:57 +01:00
'parent': {
'type': 'objectid',
#'default': '',
#'data_relation': {
# 'resource': 'nodes',
# 'field': '_id',
#},
2015-03-10 11:38:57 +01:00
},
'user': {
'type': 'objectid',
'required': True,
},
'node_type': {
'type': 'objectid',
2015-03-11 16:03:19 +01:00
'required': True,
#'data_relation': {
# 'resource': 'node_types',
# 'field': '_id',
#},
2015-03-10 11:38:57 +01:00
},
'properties': {
2015-03-11 16:03:19 +01:00
'type' : 'dict',
'valid_properties' : True,
'required': True,
},
2015-03-11 16:03:19 +01:00
}
node_types_schema = {
'name': {
'type': 'string',
'minlength': 1,
'maxlength': 128,
'required': True,
},
'description': {
'type': 'string',
'maxlength': 256,
},
2015-03-11 16:03:19 +01:00
'dyn_schema': {
'type': 'dict',
'required': True,
},
'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
}
tokens_schema = {
'user': {
'type': 'objectid',
'required': True,
},
'token': {
'type': 'string',
2015-04-08 11:47:19 -03:00
'required': True,
},
'expire_time': {
'type': 'datetime',
'required': True,
},
}
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,
'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'],
'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
}
tokens = {
'resource_methods': ['GET', 'POST'],
# Allow 'token' to be returned with POST responses
2015-04-08 11:47:19 -03:00
#'extra_response_fields': ['token'],
'schema' : tokens_schema
}
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,
'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
}
try:
os.environ['TEST_ATTRACT']
MONGO_DBNAME = 'attract_test'
except:
pass