Adding File collection (pictures)

This commit is contained in:
Eibriel
2015-04-20 08:56:22 -03:00
parent 18cc04e713
commit 7f3eca0475
2 changed files with 54 additions and 56 deletions

View File

@@ -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()

View File

@@ -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: