12 lines
327 B
Python
12 lines
327 B
Python
from rest_framework.permissions import BasePermission
|
|
|
|
from apps.accounts.models import Role
|
|
|
|
|
|
class IsStudent(BasePermission):
|
|
message = "Only students can perform this action."
|
|
|
|
def has_permission(self, request, view):
|
|
u = request.user
|
|
return bool(u and u.is_authenticated and u.role == Role.STUDENT)
|