From 744f9946e508d512ba645ba93eaeeeffb9b74423 Mon Sep 17 00:00:00 2001 From: lander Date: Wed, 27 Mar 2024 15:57:22 +0100 Subject: [PATCH] fix: linting errors on #131 --- backend/api/permissions/student_permissions.py | 2 +- backend/api/permissions/teacher_permissions.py | 2 +- backend/api/views/student_view.py | 2 +- backend/api/views/teacher_view.py | 1 + backend/authentication/models.py | 1 + 5 files changed, 5 insertions(+), 3 deletions(-) diff --git a/backend/api/permissions/student_permissions.py b/backend/api/permissions/student_permissions.py index abd1a596..182a229c 100644 --- a/backend/api/permissions/student_permissions.py +++ b/backend/api/permissions/student_permissions.py @@ -2,11 +2,11 @@ from api.permissions.role_permissions import is_teacher from authentication.models import User + class StudentPermission(IsAuthenticated): def has_permission(self, request, view): """Check if user has permission to view a general student endpoint.""" - user: User = request.user if view.action in ['list', 'create', 'update', 'partial_update', 'destroy']: return False return True diff --git a/backend/api/permissions/teacher_permissions.py b/backend/api/permissions/teacher_permissions.py index 7a31d3c6..9a7c10ad 100644 --- a/backend/api/permissions/teacher_permissions.py +++ b/backend/api/permissions/teacher_permissions.py @@ -1,12 +1,12 @@ from rest_framework.permissions import IsAuthenticated, SAFE_METHODS from authentication.models import User + # (Almost) same as StudentPermission class TeacherPermission(IsAuthenticated): def has_permission(self, request, view): """Check if user has permission to view a general Teacher endpoint.""" - user: User = request.user if view.action in ['list', 'create', 'update', 'partial_update', 'destroy']: return False return True diff --git a/backend/api/views/student_view.py b/backend/api/views/student_view.py index 28348cbf..1261d6ab 100644 --- a/backend/api/views/student_view.py +++ b/backend/api/views/student_view.py @@ -18,7 +18,7 @@ class StudentViewSet(viewsets.ModelViewSet): @action(detail=True) def courses(self, request, **_): """Returns a list of courses for the given student""" - student = self.get_object() + student = self.get_object() courses = student.courses.all() # Serialize the course objects diff --git a/backend/api/views/teacher_view.py b/backend/api/views/teacher_view.py index 4d723d44..cdc6160d 100644 --- a/backend/api/views/teacher_view.py +++ b/backend/api/views/teacher_view.py @@ -8,6 +8,7 @@ from api.permissions.teacher_permissions import TeacherPermission from rest_framework.permissions import IsAuthenticated + class TeacherViewSet(ModelViewSet): queryset = Teacher.objects.all() serializer_class = TeacherSerializer diff --git a/backend/authentication/models.py b/backend/authentication/models.py index adce2eb7..dff350cb 100644 --- a/backend/authentication/models.py +++ b/backend/authentication/models.py @@ -49,6 +49,7 @@ def get_dummy_admin(): is_staff=True ) + class Faculty(models.Model): """This model represents a faculty."""