2015-02-04 02:02:21 +01:00
|
|
|
from application import app
|
2015-04-10 13:08:45 -03:00
|
|
|
from application import post_item
|
2015-02-04 02:02:21 +01:00
|
|
|
from flask.ext.script import Manager
|
|
|
|
|
|
|
|
manager = Manager(app)
|
2015-04-07 14:31:41 +02:00
|
|
|
|
2015-04-01 10:10:26 -03:00
|
|
|
@manager.command
|
|
|
|
def runserver():
|
|
|
|
try:
|
2015-04-01 10:42:27 -03:00
|
|
|
import config
|
|
|
|
PORT = config.Development.PORT
|
|
|
|
HOST = config.Development.HOST
|
|
|
|
DEBUG = config.Development.DEBUG
|
2015-04-01 10:10:26 -03:00
|
|
|
except ImportError:
|
2015-04-07 14:31:41 +02:00
|
|
|
PORT = 5000
|
2015-04-01 10:10:26 -03:00
|
|
|
HOST = '0.0.0.0'
|
|
|
|
DEBUG = True
|
|
|
|
|
|
|
|
app.run(
|
|
|
|
port=PORT,
|
|
|
|
host=HOST,
|
|
|
|
debug=DEBUG)
|
|
|
|
|
2015-04-07 14:40:39 +02:00
|
|
|
|
2015-04-08 18:09:04 +02:00
|
|
|
@manager.command
|
|
|
|
def clear_db():
|
|
|
|
"""Wipes the database
|
|
|
|
"""
|
|
|
|
from pymongo import MongoClient
|
|
|
|
|
|
|
|
client = MongoClient()
|
|
|
|
db = client.eve
|
|
|
|
db.drop_collection('nodes')
|
|
|
|
db.drop_collection('node_types')
|
|
|
|
db.drop_collection('tokens')
|
|
|
|
db.drop_collection('users')
|
|
|
|
|
|
|
|
|
2015-04-13 15:08:44 -03:00
|
|
|
@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)
|
|
|
|
|
|
|
|
|
2015-04-07 14:40:39 +02:00
|
|
|
@manager.command
|
|
|
|
def populate_db_test():
|
|
|
|
"""Populate the db with sample data
|
|
|
|
"""
|
2015-04-13 15:08:44 -03:00
|
|
|
populate_node_types()
|
|
|
|
|
2015-04-07 14:40:39 +02:00
|
|
|
|
2015-04-13 15:08:44 -03:00
|
|
|
def populate_node_types(old_ids={}):
|
2015-04-07 14:40:39 +02:00
|
|
|
shot_node_type = {
|
|
|
|
"name": "shot",
|
|
|
|
"description": "Shot Node Type, for shots",
|
|
|
|
"dyn_schema": {
|
|
|
|
"url": {
|
|
|
|
"type": "string",
|
|
|
|
},
|
|
|
|
"cut_in": {
|
|
|
|
"type": "integer"
|
|
|
|
},
|
|
|
|
"cut_out": {
|
|
|
|
"type": "integer"
|
|
|
|
},
|
|
|
|
"status": {
|
|
|
|
"type": "string",
|
|
|
|
"allowed": ["on_hold",
|
|
|
|
"todo",
|
|
|
|
"in_progress",
|
|
|
|
"review_required",
|
|
|
|
"final"],
|
|
|
|
},
|
|
|
|
"notes": {
|
|
|
|
"type": "string",
|
|
|
|
"maxlength": 256,
|
|
|
|
},
|
|
|
|
"order": {
|
|
|
|
"type": "integer",
|
|
|
|
},
|
|
|
|
"shot_group": {
|
|
|
|
"type": "string",
|
|
|
|
#"data_relation": {
|
|
|
|
# "resource": "nodes",
|
|
|
|
# "field": "_id",
|
|
|
|
#},
|
|
|
|
}
|
|
|
|
},
|
2015-04-13 15:08:44 -03:00
|
|
|
"form_schema": {
|
|
|
|
"url": {},
|
|
|
|
"cut_in": {},
|
|
|
|
"cut_out": {},
|
|
|
|
"status": {},
|
|
|
|
"notes": {},
|
|
|
|
"order": {},
|
|
|
|
"shot_group": {}
|
|
|
|
},
|
|
|
|
"parent": {
|
|
|
|
"node_types": []
|
|
|
|
}
|
2015-04-10 13:08:45 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
task_node_type = {
|
|
|
|
"name": "task",
|
|
|
|
"description": "Task Node Type, for tasks",
|
|
|
|
"dyn_schema": {
|
|
|
|
"status": {
|
|
|
|
"type": "string",
|
|
|
|
"allowed": [
|
|
|
|
"todo",
|
|
|
|
"in-progress",
|
|
|
|
"done",
|
|
|
|
"cbb",
|
|
|
|
"final1",
|
|
|
|
"final2",
|
|
|
|
"review"
|
|
|
|
],
|
|
|
|
"required": True,
|
|
|
|
},
|
|
|
|
"owners": {
|
|
|
|
"type": "dict",
|
|
|
|
"schema": {
|
|
|
|
"users": {
|
|
|
|
"type": "list",
|
2015-04-14 12:04:50 -03:00
|
|
|
"schema": {
|
2015-04-15 10:25:31 -03:00
|
|
|
"type": "objectid",
|
2015-04-14 12:04:50 -03:00
|
|
|
}
|
2015-04-10 13:08:45 -03:00
|
|
|
},
|
|
|
|
"groups": {
|
|
|
|
"type": "list",
|
2015-04-14 12:04:50 -03:00
|
|
|
"schema": {
|
2015-04-15 10:25:31 -03:00
|
|
|
"type": "objectid",
|
2015-04-14 12:04:50 -03:00
|
|
|
}
|
2015-04-10 13:08:45 -03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"time": {
|
|
|
|
"type": "dict",
|
|
|
|
"schema": {
|
|
|
|
"start": {
|
|
|
|
"type": "datetime"
|
|
|
|
},
|
|
|
|
"duration": {
|
|
|
|
"type": "integer"
|
|
|
|
},
|
|
|
|
"chunks": {
|
|
|
|
"type": "list",
|
2015-04-13 15:08:44 -03:00
|
|
|
"schema": {
|
|
|
|
"type": "dict",
|
|
|
|
"schema": {
|
|
|
|
"start": {
|
|
|
|
"type": "datetime",
|
|
|
|
},
|
|
|
|
"duration": {
|
|
|
|
"type": "integer",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"form_schema": {
|
|
|
|
"status": {},
|
|
|
|
"owners": {
|
|
|
|
"schema": {
|
2015-04-15 10:25:31 -03:00
|
|
|
"users":{
|
|
|
|
"items": ['User'],
|
|
|
|
},
|
2015-04-13 15:08:44 -03:00
|
|
|
"groups":{}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"time": {
|
|
|
|
"schema": {
|
|
|
|
"start": {},
|
|
|
|
"duration": {},
|
|
|
|
"chunks": {
|
|
|
|
"visible": False,
|
|
|
|
"schema": {
|
|
|
|
"start":{},
|
|
|
|
"duration":{}
|
|
|
|
}
|
2015-04-10 13:08:45 -03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2015-04-13 15:08:44 -03:00
|
|
|
"parent": {
|
|
|
|
"node_types": ["shot"],
|
2015-04-07 14:40:39 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-13 15:08:44 -03:00
|
|
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
|
|
|
|
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)
|
2015-04-07 14:40:39 +02:00
|
|
|
|
|
|
|
|
2015-03-12 15:05:10 +01:00
|
|
|
if __name__ == '__main__':
|
|
|
|
manager.run()
|