Limit a view to superuser only.
424279
def superuser_only(view_func):
    
    def _inner(request, *args, **kwargs):
        if not request.user.is_superuser:
            raise PermissionDenied
        return view_func(request, *args, **kwargs)
    return _inner
503100
def login_required(view):
    """"""

    @functools.wraps(view)
    def wrapped_view(**kwargs):
        if g.user is None:
            return redirect(url_for("auth.login"))

        return view(**kwargs)

    return wrapped_view
1330154
def revoke_member(context, request):
    """"""

    mapping = request.json['mapping']
    for entry in mapping:
        user = entry['user']
        roles = entry['roles']
        username = user.get('username', None)
        userid = user.get('userid', None)
        if userid:
            u = context.get_user_by_userid(userid)
        elif username:
            u = context.get_user_by_username(username)
        else:
            u = None
        if u is None:
            raise UnprocessableError(
                'User %s does not exists' % (userid or username))
        for rolename in roles:
            context.revoke_member_role(u.userid, rolename)
    return {'status': 'success'}
1059195
def limit(self, value):
        
        self._query = self._query.limit(value)

        return self
1304270
private boolean isTilingViewAllowed() {

        if (m_types.size() == 0) {
            return false;
        }
        for (String typeName : m_types) {
            if (!isImagelikeType(typeName)) {
                return false;
            }
        }
        return true;

    }
843328
def filter_by_user(self, user):
        """"""

        return self.filter(Q(users=user) | Q(groups__in=user.groups.all()))
1299152
async def disable(self):
        
        await self.controller.disable_user(self.username)
        self._user_info.disabled = True
217449
def limit(self, limit):
        """"""
        clone = self._clone()

        if isinstance(limit, int):
            clone._limit = limit

        return clone
176107
async def revoke(self):
        
        await self.controller.revoke(self.username)
        self._user_info.access = ''
106767
def ajax_only(view_func):
    """"""

    @wraps(view_func, assigned=available_attrs(view_func))
    def _wrapped_view(request, *args, **kwargs):
        if request.is_ajax():
            return view_func(request, *args, **kwargs)
        else:
            return http.HttpResponseBadRequest()
    return _wrapped_view
1025163
def clean(self):
        
        super().clean()
        if (
            (self.user is None and not self.anonymous_user) or
            (self.user and self.anonymous_user)
        ):
            raise ValidationError(
                _('A permission should target either a user or an anonymous user'),
            )
1004176
def set_access_control(self, mode, onerror = None):
        """"""
        request.SetAccessControl(display = self.display,
                                 onerror = onerror,
                                 mode = mode)
1286593
def _allowAnotherAt(cls, parent):
        """"""
        site = parent.get_site()
        if site is None:
            return False
        return not cls.peers().descendant_of(site.root_page).exists()
635442
def run(self, value, errors, request):
        """"""
        thing = super(ViewableDBThing, self).run(value, errors, request)
        if errors:
            return None
        if not thing.can_view(request.user):
            message = 'Insufficient permissions for {0}'.format(self.param)
            raise HTTPForbidden(message)
        return thing
926005
def allow_rwe(self, name):
        """"""
        assert name in PERMISSIONS.keys()
        os.chmod(self.file_path, PERMISSIONS[name]['all'])
102813
def delete_view(self, request, object_id, extra_context=None):
        """"""
        if not extra_context:
            extra_context = {}
        extra_context['is_popup'] = request.REQUEST.get('_popup', 0)
        return super(EnhancedAdminMixin, self).delete_view(request, object_id, extra_context)
694933
public CmsLockFilter filterNotLockableByUser(CmsUser user) {

        CmsLockFilter filter = (CmsLockFilter)clone();
        filter.m_notLockableByUser = user;
        return filter;
    }