gold eggs backend
Some checks failed
Build and Push to Docker Hub / build-test-push (push) Failing after 1m55s
Some checks failed
Build and Push to Docker Hub / build-test-push (push) Failing after 1m55s
This commit is contained in:
1
core/http/permissions/__init__.py
Normal file
1
core/http/permissions/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from .base_permissions import * # noqa
|
||||
16
core/http/permissions/base_permissions.py
Normal file
16
core/http/permissions/base_permissions.py
Normal file
@@ -0,0 +1,16 @@
|
||||
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
|
||||
Reference in New Issue
Block a user