def deleteVariant(cls, variantID): session = Session() variantIndex = CommandVariants.getIndexFromVariantID(variantID) result = session.query(CommandVariants).filter(CommandVariants.i == variantIndex).first() if result is None: session.close() return {'id':variantID} session.delete(result) session.commit() session.close() return {'id':variantID}
def deleteCommand(cls, commandID): session = Session() commandIndex = UserCommands.getIndexFromCommandID(commandID) result = session.query(UserCommands).filter(UserCommands.i == commandIndex).first() if result is None: session.close() return {'id':commandID} session.delete(result) result = session.query(CommandVariants).filter(CommandVariants.usrcmdfk == commandIndex).all() for r in result: session.delete(result) session.commit() session.close() return {'id':commandID}
def deleteCategory(cls, categoryID): session = Session() categoryIndex = CommandCategories.getIndexFromCategoryID(categoryID) result = session.query(CommandCategories).filter(CommandCategories.i == categoryIndex).first() if result: session.delete(result) result = session.query(UserCommands).filter(UserCommands.categoryfk == categoryIndex).all() for r in result: session.delete(r) variants = session.query(CommandVariants).filter(CommandVariants.usrcmdfk == r.i).all() for v in variants: session.delete(v) session.commit() session.close() return {'id':categoryID}