Spaces:
Runtime error
Runtime error
Download auth_app/utils.py from neurostack-in/pms_server: direct link, hf CLI and curl.
- Browser
- Download file 575 Bytes
-
https://huggingface.co/spaces/neurostack-in/pms_server/resolve/main/auth_app/utils.py
- Command line
-
hf download hf://spaces/neurostack-in/pms_server/auth_app/utils.py
-
curl -L -o utils.py https://huggingface.co/spaces/neurostack-in/pms_server/resolve/main/auth_app/utils.py
575 Bytes
| from rest_framework.permissions import BasePermission | |
| class IsAdmin(BasePermission): | |
| """ | |
| Custom permission to only allow admin users to access the view. | |
| """ | |
| def has_permission(self, request, view): | |
| return request.user and request.user.is_authenticated and request.user.role == 'ADMIN' | |
| class IsNotFrozen(BasePermission): | |
| """ | |
| Custom permission to prevent frozen accounts from accessing views. | |
| """ | |
| def has_permission(self, request, view): | |
| return request.user and request.user.is_authenticated and request.user.status != 'FROZEN' |