(function)
return _inner
Decorator that forces a view to be accessible by SUPERUSERS only.
Decorator that forces a view to be accessible by SUPERUSERS only.
Decorator that forces a view to be accessible by SUPERUSERS only .
def superuser_protected(function):
    """Decorator that forces a view to be accessible by SUPERUSERS only.
    """
    def _inner(request, *args, **kwargs):
        if not auth.get_user(request).is_superuser:
            return HttpResponse(
                json.dumps({
                    'error': 'unauthorized_request'
                }),
                status=403,
                content_type="application/json"
            )
        return function(request, *args, **kwargs)
    return _inner
def superuser_protected ( function ) : def _inner ( request , * args , * * kwargs ) : if not auth . get_user ( request ) . is_superuser : return HttpResponse ( json . dumps ( { 'error' : 'unauthorized_request' } ) , status = 403 , content_type = "application/json" ) return function ( request , * args , * * kwargs ) return _inner