Remove permission-ViewMenu object to Role

            :param role:
                The role object
            :param perm_view:
                The PermissionViewMenu object
481393
def del_permission_role(self, role, perm_view):
        
        if perm_view in role.permissions:
            try:
                role.permissions.remove(perm_view)
                self.get_session.merge(role)
                self.get_session.commit()
                log.info(
                    c.LOGMSG_INF_SEC_DEL_PERMROLE.format(str(perm_view), role.name)
                )
            except Exception as e:
                log.error(c.LOGMSG_ERR_SEC_DEL_PERMROLE.format(str(e)))
                self.get_session.rollback()
50828
public function permissions(Role $role)
    {
        $this->authorize('manage_permissions', Role::class);

        return view('laralum_roles::permissions', ['permissions' => Permission::all(), 'role' => $role]);
    }
446105
def find_permissions_view_menu(self, view_menu):
        
        return (
            self.get_session.query(self.permissionview_model)
            .filter_by(view_menu_id=view_menu.id)
            .all()
        )
124193
def role_remove(role, **kwargs):
    '''
    
    '''
    try:
        conn = _get_connection(**kwargs)
        conn.autocommit(True)
        cur = conn.cursor()
        cur.execute('DROP ROLE {0}'.format(role))
        conn.autocommit(True)
        conn.close()
        return True
    except Exception as e:
        return 'Could not create the role: {0}'.format(e)
204799
def remove_role(*_, role_handle=None, user_id=None):
    
    click.echo(green('\nRemoving role from user:'))
    click.echo(green('-' * 40))
    with get_app().app_context():
        user = find_user(dict(id=user_id))
        if not user:
            click.echo(red('User not found\n'))
            return

        remove_role = None
        for role in user.roles:
            if role.handle == role_handle:
                remove_role = role

        if not remove_role:
            click.echo(red('User does not have such role\n'))
            return

        user_service.remove_role_from_user(user, remove_role)
        msg = 'Role "{}" removed from user "{}"\n'.format(
            remove_role.handle,
            user.email
        )
        click.echo(green(msg))
        return
987161
public String checkAccess (Permission perm, Object context)
    {
        if (_permPolicy == null) {
            _permPolicy = createPermissionPolicy();
        }
        return _permPolicy.checkAccess(perm, context);
    }
1035514
def add_permission_role(self, role, perm_view):
        
        if perm_view not in role.permissions:
            try:
                role.permissions.append(perm_view)
                self.get_session.merge(role)
                self.get_session.commit()
                log.info(
                    c.LOGMSG_INF_SEC_ADD_PERMROLE.format(str(perm_view), role.name)
                )
            except Exception as e:
                log.error(c.LOGMSG_ERR_SEC_ADD_PERMROLE.format(str(e)))
                self.get_session.rollback()
357438
def del_permission(self, role, name):
        
        if not self.has_permission(role, name):
            return True
        targetGroup = AuthGroup.objects(role=role, creator=self.client).first()
        target = AuthPermission.objects(groups=targetGroup, name=name, creator=self.client).first()
        if not target:
            return True
        target.delete()
        return True
1331843
def find_permission_view_menu(self, permission_name, view_menu_name):
        
        permission = self.find_permission(permission_name)
        view_menu = self.find_view_menu(view_menu_name)
        if permission and view_menu:
            return self.permissionview_model.objects(
                permission=permission, view_menu=view_menu
            ).first()
592220
function removeRolePrivilege (access, role, privilege) {
  if (role === true) {
    access[privilege] = {
      role: []
    }
    return
  }

  if (access[privilege].role === true) {
    access[privilege].role = true
  }

  _.pullAll(access[privilege].role, _.concat(role))
}
635104
def set_model_permissions(context, token):
    
    model = context[token.split_contents()[1]]
    opts = model._meta
    perm_name = opts.app_label + ".%s_" + opts.object_name.lower()
    request = context["request"]
    setattr(model, "perms", {})
    for perm_type in ("add", "change", "delete"):
        model.perms[perm_type] = request.user.has_perm(perm_name % perm_type)
    return ""
380741
def update_permission(obj, data):
    """"""
    full_permissions = get_all_perms(obj)

    def apply_perm(perm_func, perms, entity):
        """Apply permissions using given ``perm_func``.

        ``perm_func`` is intended to be ``assign_perms`` or
        ``remove_perms`` shortcut function from ``django-guardian``, but
        can be any function that accepts permission codename,
        user/group and object parameters (in this order).

        If given permission does not exist, ``exceptions.ParseError`` is
        raised.

        "ALL" passed as ``perms`` parameter, will call ``perm_function``
        with ``full_permissions`` list.

        :param func perm_func: Permissions function to be applied
        :param list params: list of params to be allpied
        :param entity: user or group to be passed to ``perm_func``
        :type entity: `~django.contrib.auth.models.User` or
            `~django.contrib.auth.models.Group`

        """
        if perms == 'ALL':
            perms = full_permissions
        for perm in perms:
            perm_codename = get_full_perm(perm, obj)
            if perm_codename not in full_permissions:
                raise exceptions.ParseError("Unknown permission: {}".format(perm))
            perm_func(perm_codename, entity, obj)

    def set_permissions(entity_type, perm_type):
        """Set object permissions."""
        perm_func = assign_perm if perm_type == 'add' else remove_perm
        fetch_fn = fetch_user if entity_type == 'users' else fetch_group

        for entity_id in data.get(entity_type, {}).get(perm_type, []):
            entity = fetch_fn(entity_id)
            if entity:
                perms = data[entity_type][perm_type][entity_id]
                apply_perm(perm_func, perms, entity)

    def set_public_permissions(perm_type):
        """Set public permissions."""
        perm_func = assign_perm if perm_type == 'add' else remove_perm
        user = AnonymousUser()
        perms = data.get('public', {}).get(perm_type, [])
        apply_perm(perm_func, perms, user)

    with transaction.atomic():
        set_permissions('users', 'add')
        set_permissions('users', 'remove')
        set_permissions('groups', 'add')
        set_permissions('groups', 'remove')
        set_public_permissions('add')
        set_public_permissions('remove')
268609
def remove_perm(perm, group):
    
    if not isinstance(perm, Permission):
        try:
            app_label, codename = perm.split('.', 1)
        except ValueError:
            raise ValueError("For global permissions, first argument must be in"
                             " format: 'app_label.codename' (is %r)" % perm)
        perm = Permission.objects.get(content_type__app_label=app_label, codename=codename)

    group.permissions.remove(perm)
    return
1139283
def set_role_perm(role_id, perm_id,**kwargs):
    
    #check_perm(kwargs.get('user_id'), 'edit_perm')

    _get_perm(perm_id)
    role_i = _get_role(role_id)
    roleperm_i = RolePerm(role_id=role_id, perm_id=perm_id)

    role_i.roleperms.append(roleperm_i)

    db.DBSession.flush()

    return role_i
242178
def delete_role_perm(role_id, perm_id,**kwargs):
    
    #check_perm(kwargs.get('user_id'), 'edit_perm')
    _get_perm(perm_id)
    _get_role(role_id)

    try:
        roleperm_i = db.DBSession.query(RolePerm).filter(RolePerm.role_id==role_id, RolePerm.perm_id==perm_id).one()
        db.DBSession.delete(roleperm_i)
    except NoResultFound:
        raise ResourceNotFoundError("Role Perm does not exist")

    return 'OK'
1123575
def remove_user(self, user_name, role):
        
        role_uri = self._get_role_uri(role=role)
        return self.api.delete(path=role_uri, data={'username': user_name})
585324
def editpermissions_user_view(self, request, user_id, forum_id=None):
        
        user_model = get_user_model()
        user = get_object_or_404(user_model, pk=user_id)
        forum = get_object_or_404(Forum, pk=forum_id) if forum_id else None

        # Set up the context
        context = self.get_forum_perms_base_context(request, forum)
        context['forum'] = forum
        context['title'] = '{} - {}'.format(_('Forum permissions'), user)
        context['form'] = self._get_permissions_form(
            request, UserForumPermission, {'forum': forum, 'user': user},
        )

        return render(request, self.editpermissions_user_view_template_name, context)