Changes to node_schema
Now we use ObjectId for the user field and media for the picture field (previously known as thumbnail).
This commit is contained in:
parent
1b85823f9b
commit
39544e96da
@ -77,7 +77,7 @@ class TokensAuth(TokenAuth):
|
|||||||
token_data = {
|
token_data = {
|
||||||
'user': user_id,
|
'user': user_id,
|
||||||
'token': token,
|
'token': token,
|
||||||
'expire_time': datetime.now()+timedelta(hours=1)
|
'expire_time': datetime.now() + timedelta(hours=1)
|
||||||
}
|
}
|
||||||
post_internal('tokens', token_data)
|
post_internal('tokens', token_data)
|
||||||
else:
|
else:
|
||||||
@ -101,7 +101,7 @@ class BasicsAuth(BasicAuth):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
class MyTokenAuth(BasicsAuth):
|
class CustomTokenAuth(BasicsAuth):
|
||||||
"""Switch between Basic and Token auth"""
|
"""Switch between Basic and Token auth"""
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.token_auth = TokensAuth()
|
self.token_auth = TokensAuth()
|
||||||
@ -140,4 +140,4 @@ def post_item(entry, data):
|
|||||||
post_internal(entry, data)
|
post_internal(entry, data)
|
||||||
|
|
||||||
|
|
||||||
app = Eve(validator=ValidateCustomFields, auth=MyTokenAuth)
|
app = Eve(validator=ValidateCustomFields, auth=CustomTokenAuth)
|
||||||
|
@ -127,7 +127,7 @@ def populate_db_test():
|
|||||||
shot = {
|
shot = {
|
||||||
"name": "01",
|
"name": "01",
|
||||||
"description": "A sheep tries to hang itself, but fails",
|
"description": "A sheep tries to hang itself, but fails",
|
||||||
"thumbnail": "/tmp/attrackt-thumbnail.png",
|
"picture": "",
|
||||||
"order": 0,
|
"order": 0,
|
||||||
"parent": None,
|
"parent": None,
|
||||||
"node_type": "55016a52135d32466fc800be",
|
"node_type": "55016a52135d32466fc800be",
|
||||||
|
@ -30,18 +30,7 @@ users_schema = {
|
|||||||
'type': 'list',
|
'type': 'list',
|
||||||
'allowed': ["admin"],
|
'allowed': ["admin"],
|
||||||
'required': True,
|
'required': True,
|
||||||
},
|
|
||||||
# An embedded 'strongly-typed' dictionary.
|
|
||||||
'location': {
|
|
||||||
'type': 'dict',
|
|
||||||
'schema': {
|
|
||||||
'address': {'type': 'string'},
|
|
||||||
'city': {'type': 'string'}
|
|
||||||
}
|
}
|
||||||
},
|
|
||||||
'born': {
|
|
||||||
'type': 'datetime',
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nodes_schema = {
|
nodes_schema = {
|
||||||
@ -56,10 +45,8 @@ nodes_schema = {
|
|||||||
'minlength': 0,
|
'minlength': 0,
|
||||||
'maxlength': 128,
|
'maxlength': 128,
|
||||||
},
|
},
|
||||||
'thumbnail': {
|
'picture': {
|
||||||
'type': 'string',
|
'type': 'media'
|
||||||
'minlength': 0,
|
|
||||||
'maxlength': 128,
|
|
||||||
},
|
},
|
||||||
'order': {
|
'order': {
|
||||||
'type': 'integer',
|
'type': 'integer',
|
||||||
@ -74,7 +61,7 @@ nodes_schema = {
|
|||||||
#},
|
#},
|
||||||
},
|
},
|
||||||
'user': {
|
'user': {
|
||||||
'type': 'string',
|
'type': 'objectid',
|
||||||
'required': True,
|
'required': True,
|
||||||
},
|
},
|
||||||
'node_type': {
|
'node_type': {
|
||||||
@ -92,7 +79,6 @@ nodes_schema = {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
node_types_schema = {
|
node_types_schema = {
|
||||||
'name': {
|
'name': {
|
||||||
'type': 'string',
|
'type': 'string',
|
||||||
@ -110,7 +96,6 @@ node_types_schema = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
tokens_schema = {
|
tokens_schema = {
|
||||||
'user': {
|
'user': {
|
||||||
'type': 'objectid',
|
'type': 'objectid',
|
||||||
@ -126,7 +111,6 @@ tokens_schema = {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
nodes = {
|
nodes = {
|
||||||
# We choose to override global cache-control directives for this resource.
|
# We choose to override global cache-control directives for this resource.
|
||||||
'cache_control': 'max-age=10,must-revalidate',
|
'cache_control': 'max-age=10,must-revalidate',
|
||||||
@ -135,13 +119,11 @@ nodes = {
|
|||||||
'schema': nodes_schema
|
'schema': nodes_schema
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
node_types = {
|
node_types = {
|
||||||
'resource_methods': ['GET', 'POST'],
|
'resource_methods': ['GET', 'POST'],
|
||||||
'schema': node_types_schema,
|
'schema': node_types_schema,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
users = {
|
users = {
|
||||||
'item_title': 'user',
|
'item_title': 'user',
|
||||||
|
|
||||||
@ -159,7 +141,7 @@ users = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tokens = {
|
tokens = {
|
||||||
'resource_methods': ['POST'],
|
'resource_methods': ['GET', 'POST'],
|
||||||
|
|
||||||
# Allow 'token' to be returned with POST responses
|
# Allow 'token' to be returned with POST responses
|
||||||
#'extra_response_fields': ['token'],
|
#'extra_response_fields': ['token'],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user