Ilo/apps/enrollments/api/permissions.py
2026-05-02 20:01:30 +03:30

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)