def insert_new_treenode(parent_id=None, skeleton=None): """ If the parent_id is not None and the skeleton_id of the parent does not match with the skeleton.id, then the database will throw an error given that the skeleton_id, being defined as foreign key in the treenode table, will not meet the being-foreign requirement. """ new_treenode = Treenode() new_treenode.user = request.user new_treenode.editor = request.user new_treenode.project_id = project_id new_treenode.location_x = float(params['x']) new_treenode.location_y = float(params['y']) new_treenode.location_z = float(params['z']) new_treenode.radius = int(params['radius']) new_treenode.skeleton = skeleton new_treenode.confidence = int(params['confidence']) if parent_id: new_treenode.parent_id = parent_id new_treenode.save() return new_treenode
def insert_new_treenode(parent_id=None, skeleton_id=None): """ If the parent_id is not None and the skeleton_id of the parent does not match with the skeleton.id, then the database will throw an error given that the skeleton_id, being defined as foreign key in the treenode table, will not meet the being-foreign requirement. """ new_treenode = Treenode() new_treenode.user = creator new_treenode.editor = editor new_treenode.project_id = project_id if creation_time: new_treenode.creation_time = creation_time new_treenode.location_x = float(x) new_treenode.location_y = float(y) new_treenode.location_z = float(z) new_treenode.radius = int(radius) new_treenode.skeleton_id = skeleton_id new_treenode.confidence = int(confidence) if parent_id: new_treenode.parent_id = parent_id new_treenode.save() return new_treenode