pillar/attract/settings.py

170 lines
3.4 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
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-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
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-03-10 11:38:57 +01:00
}
try:
os.environ['TEST_ATTRACT']
MONGO_DBNAME = 'attract_test'
except:
pass