def _add_view_menu(self, name): """ Adds a view menu to the backend param name: name of the view menu to add """ view_menu = self.session.query(ViewMenu).filter_by(name = name).first() if view_menu == None: view_menu = ViewMenu() view_menu.name = name self.session.add(view_menu) self.session.commit() return view_menu return view_menu
def _add_view_menu(self, view_name): """ Adds a view or menu to the backend, model view_menu param name: name of the view menu to add """ view_menu = self.session.query(ViewMenu).filter_by(name=view_name).first() if view_menu is None: try: view_menu = ViewMenu() view_menu.name = view_name self.session.add(view_menu) self.session.commit() return view_menu except Exception as e: log.error("Add View Menu Error: {0}".format(str(e))) self.session.rollback() return view_menu