def createMenuItem(self, params): parent_id = int(params[0]) parent_type = unicode(params[1]) if parent_type == "menu": menu = Menu.get_menu_by_id(parent_id) Menu.create_menu_item(menu) return 0 elif parent_type == "menuItem": menu_item = MenuItem.get_menu_item_by_id(parent_id) MenuItem.create_menu_item(None,menu_item) return 0 else: return 1
def renameMenuItem(self, params): menu_item_id = int(params[0]) new_name = unicode(params[1]) menu_item = MenuItem.get_menu_item_by_id(menu_item_id) menu_item.set_name(new_name) return 0
def getMenuItemsOfMenuItem(self, params): menu_item_id = int(params[0]) menu_items = MenuItem.get_menu_item_by_id(menu_item_id).get_menu_items() ret = [] for menu_item in menu_items: ret.append({"name": menu_item.get_name(), "id": menu_item.get_id(), "order": menu_item.get_order()}) return ret
def getActionListForMenuItem(self, params): menu_item_id = int(params[0]) menu_item = MenuItem.get_menu_item_by_id(menu_item_id) action_list = menu_item.get_action_list() return {"id":action_list.get_id()}
def deleteMenuItem(self, params): menu_item_id = int(params[0]) menu_item = MenuItem.get_menu_item_by_id(menu_item_id) menu_item.delete() return 0
def moveToTopMenuItemOrder(self, params): menu_item_id = int(params[0]) menu_item = MenuItem.get_menu_item_by_id(menu_item_id) menu_item.move_to_top_order() return 0
def decreaseMenuItemOrder(self, params): menu_item_id = int(params[0]) menu_item = MenuItem.get_menu_item_by_id(menu_item_id) menu_item.decrease_order() return 0