12 lines
474 B
Python
12 lines
474 B
Python
from rest_framework.permissions import BasePermission
|
|
|
|
|
|
class IsAdminAccount(BasePermission):
|
|
"""Allows access only to authenticated staff/superuser accounts."""
|
|
|
|
message = 'دسترسی غیرمجاز. فقط مدیران میتوانند به این بخش دسترسی داشته باشند.'
|
|
|
|
def has_permission(self, request, view):
|
|
user = request.user
|
|
return bool(user and user.is_authenticated and (user.is_staff or user.is_superuser))
|