def _add_permission_view_menu(self, permission_name, view_menu_name): """ Adds a permission on a view menu to the backend param permission_name: name of the permission to add: 'can_add','can_edit' etc... param view_menu_name: name of the view menu to add """ vm = self._add_view_menu(view_menu_name) perm = self._add_permission(permission_name) pv = PermissionView() pv.view_menu_id, pv.permission_id = vm.id, perm.id self.session.add(pv) self.session.commit() print "Added Permission View" , str(pv) return pv
def _add_permission_view_menu(self, permission_name, view_menu_name): """ Adds a permission on a view or menu to the backend :param permission_name: name of the permission to add: 'can_add','can_edit' etc... :param view_menu_name: name of the view menu to add """ vm = self._add_view_menu(view_menu_name) perm = self._add_permission(permission_name) pv = PermissionView() pv.view_menu_id, pv.permission_id = vm.id, perm.id try: self.session.add(pv) self.session.commit() log.info("Added Permission View %s" % (str(pv))) return pv except Exception as e: log.error("Add Permission to View Error: {0}".format(str(e))) self.session.rollback()