Skip to content

Commit

Permalink
chore: linting
Browse files Browse the repository at this point in the history
  • Loading branch information
EwoutV committed Mar 8, 2024
1 parent fe9c170 commit bdb9d9e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions backend/api/permissions/course_permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

class CoursePermission(BasePermission):
"""Permission class used as default policy for course endpoints."""

def has_permission(self, request: Request, view: ViewSet) -> bool:
"""Check if user has permission to view a general course endpoint."""
user: User = request.user
Expand All @@ -34,6 +35,7 @@ def has_object_permission(self, request: Request, view: ViewSet, course: Course)

class CourseAssistantPermission(CoursePermission):
"""Permission class for assistant related endpoints."""

def has_object_permission(self, request: Request, view: ViewSet, course: Course) -> bool:
user: User = request.user

Expand All @@ -47,6 +49,7 @@ def has_object_permission(self, request: Request, view: ViewSet, course: Course)

class CourseStudentPermission(CoursePermission):
"""Permission class for student related endpoints."""

def has_object_permission(self, request: Request, view: ViewSet, course: Course):
user: User = request.user

Expand All @@ -64,6 +67,7 @@ def has_object_permission(self, request: Request, view: ViewSet, course: Course)

class CourseProjectPermission(CoursePermission):
"""Permission class for project related endpoints."""

def has_object_permission(self, request: Request, view: ViewSet, course: Course):
user: User = request.user

Expand Down
3 changes: 3 additions & 0 deletions backend/api/permissions/role_permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@
def is_student(user: User):
return Student.objects.filter(id=user.id).exists()


def is_assistant(user: User):
return Assistant.objects.filter(id=user.id).exists()


def is_teacher(user: User):
return Teacher.objects.filter(id=user.id).exists()


class IsStudent(IsAuthenticated):
def has_permission(self, request: Request, view):
"""Returns true if the request contains a user,
Expand Down
1 change: 0 additions & 1 deletion backend/api/views/course_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ def _remove_assistant(self, request: Request, **_):
# Not found
raise NotFound(gettext("assistants.error.404"))


@action(detail=True, methods=["get"], permission_classes=[IsAdminUser | CourseStudentPermission])
def students(self, request, **_):
"""Returns a list of students for the given course"""
Expand Down

0 comments on commit bdb9d9e

Please sign in to comment.