from rest_framework import permissions
from pyuser.models import (USER_TYPE_ADMIN,
                           USER_TYPE_NORMAL,
                           USER_TYPE_VISITOR)


class IsAdminOrReadOnly(permissions.BasePermission):
    def has_permission(self, request, view):
        return request.user.pyuser.type == USER_TYPE_ADMIN


class IsPyUserOrReadOnly(permissions.BasePermission):
    def has_permission(self, request, view):
        return request.user.pyuser.type != USER_TYPE_VISITOR

