From 39544e96da1c02bccda918050c9614f6aca2830b Mon Sep 17 00:00:00 2001 From: Francesco Siddi Date: Mon, 13 Apr 2015 01:21:57 +0200 Subject: [PATCH] Changes to node_schema Now we use ObjectId for the user field and media for the picture field (previously known as thumbnail). --- attract/application/__init__.py | 6 +++--- attract/manage.py | 2 +- attract/settings.py | 28 +++++----------------------- 3 files changed, 9 insertions(+), 27 deletions(-) diff --git a/attract/application/__init__.py b/attract/application/__init__.py index a24a8cd6..ae8af7ac 100644 --- a/attract/application/__init__.py +++ b/attract/application/__init__.py @@ -77,7 +77,7 @@ class TokensAuth(TokenAuth): token_data = { 'user': user_id, 'token': token, - 'expire_time': datetime.now()+timedelta(hours=1) + 'expire_time': datetime.now() + timedelta(hours=1) } post_internal('tokens', token_data) else: @@ -101,7 +101,7 @@ class BasicsAuth(BasicAuth): return True -class MyTokenAuth(BasicsAuth): +class CustomTokenAuth(BasicsAuth): """Switch between Basic and Token auth""" def __init__(self): self.token_auth = TokensAuth() @@ -140,4 +140,4 @@ def post_item(entry, data): post_internal(entry, data) -app = Eve(validator=ValidateCustomFields, auth=MyTokenAuth) +app = Eve(validator=ValidateCustomFields, auth=CustomTokenAuth) diff --git a/attract/manage.py b/attract/manage.py index c1403f4b..55747b33 100644 --- a/attract/manage.py +++ b/attract/manage.py @@ -127,7 +127,7 @@ def populate_db_test(): shot = { "name": "01", "description": "A sheep tries to hang itself, but fails", - "thumbnail": "/tmp/attrackt-thumbnail.png", + "picture": "", "order": 0, "parent": None, "node_type": "55016a52135d32466fc800be", diff --git a/attract/settings.py b/attract/settings.py index e6467c12..96d91810 100644 --- a/attract/settings.py +++ b/attract/settings.py @@ -30,18 +30,7 @@ users_schema = { 'type': 'list', 'allowed': ["admin"], 'required': True, - }, - # An embedded 'strongly-typed' dictionary. - 'location': { - 'type': 'dict', - 'schema': { - 'address': {'type': 'string'}, - 'city': {'type': 'string'} - } - }, - 'born': { - 'type': 'datetime', - }, + } } nodes_schema = { @@ -56,10 +45,8 @@ nodes_schema = { 'minlength': 0, 'maxlength': 128, }, - 'thumbnail': { - 'type': 'string', - 'minlength': 0, - 'maxlength': 128, + 'picture': { + 'type': 'media' }, 'order': { 'type': 'integer', @@ -74,7 +61,7 @@ nodes_schema = { #}, }, 'user': { - 'type': 'string', + 'type': 'objectid', 'required': True, }, 'node_type': { @@ -92,7 +79,6 @@ nodes_schema = { }, } - node_types_schema = { 'name': { 'type': 'string', @@ -110,7 +96,6 @@ node_types_schema = { } } - tokens_schema = { 'user': { 'type': 'objectid', @@ -126,7 +111,6 @@ tokens_schema = { }, } - nodes = { # We choose to override global cache-control directives for this resource. 'cache_control': 'max-age=10,must-revalidate', @@ -135,13 +119,11 @@ nodes = { 'schema': nodes_schema } - node_types = { 'resource_methods': ['GET', 'POST'], 'schema': node_types_schema, } - users = { 'item_title': 'user', @@ -159,7 +141,7 @@ users = { } tokens = { - 'resource_methods': ['POST'], + 'resource_methods': ['GET', 'POST'], # Allow 'token' to be returned with POST responses #'extra_response_fields': ['token'],