views.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:itaplay 作者: lhalam 项目源码 文件源码
def check_superadmin(func):
    """
    Decorator that check if authenticated user is a superadmin.
    :param func: function, that be wrapped
    :return: function
    """
    def wrapper(self, request, *args, **kwargs):
        """
        Wrapper, that checks authenticated user
        :param request: Django request
        :return: BadRequest when authenticated user is not a superadmin or function in other case
        """
        if not request.user.is_superuser:
            return HttpResponseBadRequest("Permission denied")
        return func(self, request, *args, **kwargs)
    return wrapper
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号