Filter object objects by permissions of user in request.
555893
def _filter_queryset(self, perms, queryset):
        """"""
        user = self.request.user if self.request else AnonymousUser()
        return get_objects_for_user(user, perms, queryset)
1324874
function filterParameters(request) {
    const data = Object.assign({}, config);
    Object.keys(request).forEach((key) => {
      data[key] = request[key];
    });

    return data;
  }
631951
function filterSubmissions(req, res, next) {
  var filterParams = {
    formId: req.body.formId,
    appId: req.body.appId
  };

  logger.debug("Middleware filterSubmissions ", {params: filterParams});

  forms.getSubmissions(req.connectionOptions, filterParams, _getSubmissionsResultHandler(req, next));
}
843328
def filter_by_user(self, user):
        """"""

        return self.filter(Q(users=user) | Q(groups__in=user.groups.all()))
490782
def check_user_permissions(payload, user_pk):
    """"""
    for perm_type in ['add', 'remove']:
        user_pks = payload.get('users', {}).get(perm_type, {}).keys()
        if user_pk in user_pks:
            raise exceptions.PermissionDenied("You cannot change your own permissions")
124618
def filter_queryset(self, request, queryset, view):
        """"""
        user = request.user

        app_label = queryset.model._meta.app_label  # pylint: disable=protected-access
        model_name = queryset.model._meta.model_name  # pylint: disable=protected-access

        kwargs = {}
        if model_name == 'storage':
            model_name = 'data'
            kwargs['perms_filter'] = 'data__pk__in'

        if model_name == 'relation':
            model_name = 'collection'
            kwargs['perms_filter'] = 'collection__pk__in'

        permission = '{}.view_{}'.format(app_label, model_name)

        return get_objects_for_user(user, permission, queryset, **kwargs)
926398
def perform_permissions_check(self, user, obj, perms):
        
        return self.request.forum_permission_handler.can_access_moderation_queue(user)
1063460
def get_group_permissions(self, user_obj, obj=None):
        
        if user_obj.is_anonymous() or obj is not None:
            return set()
        if not hasattr(user_obj, '_group_perm_cache'):
            if user_obj.is_superuser:
                perms = Permission.objects.all()
            else:
                user_groups_field = get_user_class()._meta.get_field('groups')  # pylint: disable=W0212
                user_groups_query = 'group__%s' % user_groups_field.related_query_name()
                perms = Permission.objects.filter(**{user_groups_query: user_obj})
            perms = perms.values_list('content_type__app_label', 'codename').order_by()
            user_obj._group_perm_cache = set(["%s.%s" % (ct, name) for ct, name in perms])  # pylint: disable=W0212
        return user_obj._group_perm_cache
535168
def create_api_object_group_permission(self):
        """"""

        return ApiObjectGroupPermission(
            self.networkapi_url,
            self.user,
            self.password,
            self.user_ldap)
424554
def has_permissions(self, object, group, operations):
        ''''''
        if self.is_superuser:
            return 1
        else:
            models = self.session.router
            # valid permissions
            query = models.permission.for_object(object, operation=operations)
            objects = models[models.role.permissions.model]
            return objects.filter(role=self.role.query(),
                                  permission=query).count()
200973
def check_owner_permission(payload, allow_user_owner):
    """"""
    for entity_type in ['users', 'groups']:
        for perm_type in ['add', 'remove']:
            for perms in payload.get(entity_type, {}).get(perm_type, {}).values():
                if 'owner' in perms:
                    if entity_type == 'users' and allow_user_owner:
                        continue

                    if entity_type == 'groups':
                        raise exceptions.ParseError("Owner permission cannot be assigned to a group")

                    raise exceptions.PermissionDenied("Only owners can grant/revoke owner permission")
534347
def filter_queryset(self, request, queryset, view):
        
        if request.user.is_superuser:
            return queryset
        return queryset.filter(status__user=request.user)
1367881
def get_permissions(self):
        """"""
        permissions = set()
        permissions.update(self.resource_manager.get_permissions())
        for f in self.resource_manager.filters:
            permissions.update(f.get_permissions())
        for a in self.resource_manager.actions:
            permissions.update(a.get_permissions())
        return permissions
1169452
def perform_permissions_check(self, user, obj, perms):
        
        return self.request.forum_permission_handler.can_approve_posts(obj, user)
1007956
def object_permission_set(self):
        '''
        
        '''
        return Or(
            AllowAdmin,
            AllowObjectPermission('team:admin'),
            AllowObjectPermission('org:admin', lambda t: t.organization_id),
            And(
                AllowOnlySafeHttpMethod,
                Or(
                    ObjAttrTrue(
                        lambda r, t: t.users.filter(pk=r.user.pk).exists()),
                    ObjAttrTrue(
                        lambda r, t: t.organization.users.filter(
                            pk=r.user.pk).exists())
                )
            )
        )
910724
def has_object_permission(self, request, view, obj):
        """"""
        # admins can do anything
        if request.user.is_superuser:
            return True

        # `share` permission is required for editing permissions
        if 'permissions' in view.action:
            self.perms_map['POST'] = ['%(app_label)s.share_%(model_name)s']

        if view.action in ['add_data', 'remove_data']:
            self.perms_map['POST'] = ['%(app_label)s.add_%(model_name)s']

        if hasattr(view, 'get_queryset'):
            queryset = view.get_queryset()
        else:
            queryset = getattr(view, 'queryset', None)

        assert queryset is not None, (
            'Cannot apply DjangoObjectPermissions on a view that '
            'does not set `.queryset` or have a `.get_queryset()` method.'
        )

        model_cls = queryset.model
        user = request.user

        perms = self.get_required_object_permissions(request.method, model_cls)

        if not user.has_perms(perms, obj) and not AnonymousUser().has_perms(perms, obj):
            # If the user does not have permissions we need to determine if
            # they have read permissions to see 403, or not, and simply see
            # a 404 response.

            if request.method in permissions.SAFE_METHODS:
                # Read permissions already checked and failed, no need
                # to make another lookup.
                raise Http404

            read_perms = self.get_required_object_permissions('GET', model_cls)
            if not user.has_perms(read_perms, obj):
                raise Http404

            # Has read permissions.
            return False

        return True
1309234
def perform_permissions_check(self, user, obj, perms):
        
        return self.request.forum_permission_handler.can_subscribe_to_topic(obj, user)