from rest_framework.permissions import BasePermission
from django.utils.translation import gettext_lazy as _


class IsRole(BasePermission):
    message = _("You must be an admin to perform this action.")

    def __init__(self, role):
        super().__init__()
        self.role = role

    def __call__(self):
        return self

    def has_permission(self, request, view):
        return request.user.role in self.role
