Python rest_framework.permissions 模块,IsAdminUser() 实例源码

我们从Python开源项目中,提取了以下5个代码示例,用于说明如何使用rest_framework.permissions.IsAdminUser()

项目:BrewCenterAPI    作者:BrewCenter    | 项目源码 | 文件源码
def get_permissions(self):
        """Define custom permissions for different methods"""

        # at minimum require users to be authenticated
        self.permission_classes = [IsAuthenticated]
        # for PUT requests require users to be admins
        if self.request.method == 'PUT':
            self.permission_classes.append(IsAdminUser)

        return super(viewsets.ViewSet, self).get_permissions()
项目:BrewCenterAPI    作者:BrewCenter    | 项目源码 | 文件源码
def get_permissions(self):
        """Define custom permissions for different methods"""

        # at minimum require users to be authenticated
        self.permission_classes = [IsAuthenticated]
        # for PUT requests require users to be admins
        if self.request.method == 'PUT':
            self.permission_classes.append(IsAdminUser)

        return super(viewsets.ViewSet, self).get_permissions()
项目:tunga-api    作者:tunga-io    | 项目源码 | 文件源码
def has_permission(self, request, view):
        if request.method in SAFE_METHODS:
            return True
        return IsAdminUser().has_permission(request, view)
项目:tunga-api    作者:tunga-io    | 项目源码 | 文件源码
def has_permission(self, request, view):
        if request.method == 'POST':
            return True
        return IsAdminUser().has_permission(request, view)
项目:balafon    作者:ljean    | 项目源码 | 文件源码
def get_staff_api_permissions():
    """get public api permissions"""
    return [permissions.IsAdminUser]