From 7f3eca0475cecfaeae9c9e59f533ac2cd48c08e6 Mon Sep 17 00:00:00 2001 From: Eibriel Date: Mon, 20 Apr 2015 08:56:22 -0300 Subject: [PATCH] Adding File collection (pictures) --- attract/manage.py | 56 --------------------------------------------- attract/settings.py | 54 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 56 deletions(-) diff --git a/attract/manage.py b/attract/manage.py index cae05ae9..e2bb7626 100644 --- a/attract/manage.py +++ b/attract/manage.py @@ -199,52 +199,6 @@ def populate_node_types(old_ids={}): } } - file_node_type= { - 'name': 'file', - 'description': 'File node type', - 'dyn_schema': { - 'contentType': { - 'type': 'string', - }, - 'length': { - 'type': 'integer', - }, - 'uploadDate': { - 'type': 'datetime', - }, - 'md5': { - 'type': 'string', - }, - 'filename': { - 'type': 'string', - }, - #'thumbnail': { - # 'type': 'string', - #}, - #'preview': { - # 'type': 'string', - #}, - #'binary_data': { - # 'type': 'media', - #}, - 'path': { - 'type': 'string', - } - }, - 'form_schema': { - 'contentType': {}, - 'length': {}, - 'uploadDate': { - 'dateonly': True, - }, - 'md5': {}, - 'filename': {}, - 'binary_data': {}, - 'path': {}, - }, - 'parent': { - } - } from pymongo import MongoClient @@ -284,15 +238,5 @@ def populate_node_types(old_ids={}): post_item('node_types', task_node_type) - task_name = file_node_type['name'] - if task_name in old_ids: - file_node_type = mix_node_type(old_ids[task_name], file_node_type) - # Remove old node_type - db.node_types.remove({'_id':old_ids[task_name]}) - # Insert new node_type - db.node_types.insert(file_node_type) - else: - post_item('node_types', file_node_type) - if __name__ == '__main__': manager.run() diff --git a/attract/settings.py b/attract/settings.py index 1345fa7e..115e3d4d 100644 --- a/attract/settings.py +++ b/attract/settings.py @@ -121,6 +121,54 @@ tokens_schema = { }, } +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, + }, + #'thumbnail': { + # 'type': 'string', + #}, + #'preview': { + # 'type': 'string', + #}, + #'binary_data': { + # 'type': 'media', + #}, + 'path': { + 'type': 'string', + 'required': True, + } +} + nodes = { 'schema': nodes_schema } @@ -155,11 +203,17 @@ tokens = { 'schema' : tokens_schema } +files = { + 'resource_methods': ['GET', 'POST'], + 'schema': files_schema, +} + DOMAIN = { 'users': users, 'nodes': nodes, 'node_types': node_types, 'tokens': tokens, + 'files': files, } try: