Coverage for apps/users/permissions.py: 64%
8 statements
« prev ^ index » next coverage.py v6.4.4, created at 2024-04-19 09:45 -0600
« prev ^ index » next coverage.py v6.4.4, created at 2024-04-19 09:45 -0600
1from rest_framework.permissions import BasePermission
4class AdminPanel(BasePermission):
5 """
6 Allows access only to authenticated users that are employees.
7 """
9 def has_permission(self, request, view):
10 return bool(request.user and request.user.is_staff)
13class UserPermission(BasePermission):
14 """
15 Allows access only to authenticated users that are users.
16 """
18 def has_permission(self, request, view):
19 if request.user.is_authenticated:
20 return (
21 hasattr(request.user, "practitioner")
22 or request.user.affiliations.exists()
23 or request.user.is_authenticated
24 )