Skip to content

Commit

Permalink
update project views and permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
Evgeniy-Golodnykh committed Aug 6, 2024
1 parent 85dad4e commit a66a33f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions blackfox/api/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class IsAdmin(permissions.BasePermission):
message = 'Only admin can perform this.'

def has_permission(self, request, view):
return request.user.is_authenticated and request.user.is_admin
return request.user.is_authenticated and request.user.role == 'admin'


class IsCoach(permissions.BasePermission):
Expand All @@ -16,4 +16,4 @@ class IsCoach(permissions.BasePermission):
message = 'Only coach can perform this.'

def has_permission(self, request, view):
return request.user.is_authenticated and request.user.coach
return request.user.is_authenticated and request.user.role == 'coach'
2 changes: 1 addition & 1 deletion blackfox/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def perform_create(self, serializer):


class ProjectViewSet(viewsets.ModelViewSet):
permission_classes = [IsAdmin, IsCoach]
permission_classes = [(IsAdmin | IsCoach)]
serializer_class = ProjectSerializer
queryset = Project.objects.all()
filter_backends = [filters.SearchFilter]
Expand Down
Binary file modified blackfox/db.sqlite3
Binary file not shown.

0 comments on commit a66a33f

Please sign in to comment.