Added upgrade_node_type command
Improved task node type Added form_schema to manipulate forms
This commit is contained in:
parent
39544e96da
commit
67d620bc37
@ -36,11 +36,30 @@ def clear_db():
|
|||||||
db.drop_collection('users')
|
db.drop_collection('users')
|
||||||
|
|
||||||
|
|
||||||
|
@manager.command
|
||||||
|
def upgrade_node_types():
|
||||||
|
"""Wipes node_types collection
|
||||||
|
and populates it again
|
||||||
|
"""
|
||||||
|
from pymongo import MongoClient
|
||||||
|
|
||||||
|
client = MongoClient()
|
||||||
|
db = client.eve
|
||||||
|
node_types = db.node_types.find({})
|
||||||
|
old_ids = {}
|
||||||
|
for nt in node_types:
|
||||||
|
old_ids[nt['name']] = nt['_id']
|
||||||
|
populate_node_types(old_ids)
|
||||||
|
|
||||||
|
|
||||||
@manager.command
|
@manager.command
|
||||||
def populate_db_test():
|
def populate_db_test():
|
||||||
"""Populate the db with sample data
|
"""Populate the db with sample data
|
||||||
"""
|
"""
|
||||||
|
populate_node_types()
|
||||||
|
|
||||||
|
|
||||||
|
def populate_node_types(old_ids={}):
|
||||||
shot_node_type = {
|
shot_node_type = {
|
||||||
"name": "shot",
|
"name": "shot",
|
||||||
"description": "Shot Node Type, for shots",
|
"description": "Shot Node Type, for shots",
|
||||||
@ -77,6 +96,18 @@ def populate_db_test():
|
|||||||
#},
|
#},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"form_schema": {
|
||||||
|
"url": {},
|
||||||
|
"cut_in": {},
|
||||||
|
"cut_out": {},
|
||||||
|
"status": {},
|
||||||
|
"notes": {},
|
||||||
|
"order": {},
|
||||||
|
"shot_group": {}
|
||||||
|
},
|
||||||
|
"parent": {
|
||||||
|
"node_types": []
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
task_node_type = {
|
task_node_type = {
|
||||||
@ -118,31 +149,84 @@ def populate_db_test():
|
|||||||
},
|
},
|
||||||
"chunks": {
|
"chunks": {
|
||||||
"type": "list",
|
"type": "list",
|
||||||
|
"schema": {
|
||||||
|
"type": "dict",
|
||||||
|
"schema": {
|
||||||
|
"start": {
|
||||||
|
"type": "datetime",
|
||||||
|
},
|
||||||
|
"duration": {
|
||||||
|
"type": "integer",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
}
|
||||||
shot = {
|
},
|
||||||
"name": "01",
|
"form_schema": {
|
||||||
"description": "A sheep tries to hang itself, but fails",
|
"status": {},
|
||||||
"picture": "",
|
"owners": {
|
||||||
"order": 0,
|
"schema": {
|
||||||
"parent": None,
|
"users":{},
|
||||||
"node_type": "55016a52135d32466fc800be",
|
"groups":{}
|
||||||
"properties": {
|
}
|
||||||
"url": "shot01",
|
},
|
||||||
"cut_in": 100,
|
"time": {
|
||||||
"cut_out": 900,
|
"schema": {
|
||||||
"status": "todo",
|
"start": {},
|
||||||
"notes": "I think the sheep should scream a bit more",
|
"duration": {},
|
||||||
"order": 1,
|
"chunks": {
|
||||||
"shot_group": "",
|
"visible": False,
|
||||||
|
"schema": {
|
||||||
|
"start":{},
|
||||||
|
"duration":{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"parent": {
|
||||||
|
"node_types": ["shot"],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
from pymongo import MongoClient
|
||||||
|
|
||||||
|
client = MongoClient()
|
||||||
|
db = client.eve
|
||||||
|
|
||||||
|
def mix_node_type(old_id, node_type_dict):
|
||||||
|
# Take eve parameters
|
||||||
|
node_type = db.node_types.find({'_id':old_id})
|
||||||
|
node_type = node_type[0]
|
||||||
|
for attr in node_type:
|
||||||
|
if attr[0]=='_':
|
||||||
|
# Mix with node type attributes
|
||||||
|
node_type_dict[attr]=node_type[attr]
|
||||||
|
return node_type_dict
|
||||||
|
|
||||||
|
|
||||||
|
shot_name = shot_node_type['name']
|
||||||
|
if shot_name in old_ids:
|
||||||
|
shot_node_type = mix_node_type(old_ids[shot_name], shot_node_type)
|
||||||
|
# Remove old node_type
|
||||||
|
db.node_types.remove({'_id':old_ids[shot_name]})
|
||||||
|
# Insert new node_type
|
||||||
|
db.node_types.insert(shot_node_type)
|
||||||
|
else:
|
||||||
post_item('node_types', shot_node_type)
|
post_item('node_types', shot_node_type)
|
||||||
|
|
||||||
|
|
||||||
|
task_name = task_node_type['name']
|
||||||
|
if task_name in old_ids:
|
||||||
|
task_node_type = mix_node_type(old_ids[task_name], task_node_type)
|
||||||
|
# Remove old node_type
|
||||||
|
db.node_types.remove({'_id':old_ids[task_name]})
|
||||||
|
# Insert new node_type
|
||||||
|
db.node_types.insert(task_node_type)
|
||||||
|
else:
|
||||||
post_item('node_types', task_node_type)
|
post_item('node_types', task_node_type)
|
||||||
|
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ nodes_schema = {
|
|||||||
},
|
},
|
||||||
'parent': {
|
'parent': {
|
||||||
'type': 'objectid',
|
'type': 'objectid',
|
||||||
'default': '',
|
#'default': '',
|
||||||
#'data_relation': {
|
#'data_relation': {
|
||||||
# 'resource': 'nodes',
|
# 'resource': 'nodes',
|
||||||
# 'field': '_id',
|
# 'field': '_id',
|
||||||
@ -93,6 +93,14 @@ node_types_schema = {
|
|||||||
'dyn_schema': {
|
'dyn_schema': {
|
||||||
'type': 'dict',
|
'type': 'dict',
|
||||||
'required': True,
|
'required': True,
|
||||||
|
},
|
||||||
|
'form_schema': {
|
||||||
|
'type': 'dict',
|
||||||
|
'required': True,
|
||||||
|
},
|
||||||
|
'parent': {
|
||||||
|
'type': 'dict',
|
||||||
|
'required': True,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user