Skip to content

Commit

Permalink
fix: feedback permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
EwoutV committed May 24, 2024
1 parent 3bec493 commit 15682e9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
11 changes: 9 additions & 2 deletions backend/api/permissions/submission_permissions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from typing import cast

from api.models.course import Course
from api.models.submission import (ExtraCheckResult, StructureCheckResult,
Submission)
from api.permissions.role_permissions import (is_assistant, is_student,
Expand Down Expand Up @@ -41,8 +42,14 @@ class SubmissionFeedbackPermission(SubmissionPermission):
def has_permission(self, request: Request, view: APIView) -> bool:
return True

def has_object_permission(self, request: Request, view: APIView, obj: Submission) -> bool:
return True
def has_object_permission(self, request: Request, view: APIView, submission: Submission) -> bool:
if is_student(request.user) and submission.group.students.contains(request.user):
return True

if is_teacher(request.user) or is_assistant(request.user):
return True

return False


class StructureCheckResultPermission(SubmissionPermission):
Expand Down
2 changes: 1 addition & 1 deletion backend/api/views/feedback_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from api.serializers.feedback_serializer import FeedbackSerializer


class FeedbackViewSet(viewsets.ModelViewSet):
class FeedbackViewSet(viewsets.ReadOnlyModelViewSet):
queryset = Feedback.objects.all()
serializer_class = FeedbackSerializer
permission_classes = [IsAdminOrTeacherForPatch]
4 changes: 2 additions & 2 deletions frontend/src/views/submissions/SubmissionView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ watchImmediate(
<template v-if="submission !== null">
<div class="fadein grid">
<!-- Submission properties -->
<div class="col-6 md:col-4">
<div class="col-12 md:col-4">
<!-- Submission status -->
<div class="mb-5">
<Title class="flex">Status</Title>
Expand Down Expand Up @@ -159,7 +159,7 @@ watchImmediate(
</template>
</div>
<!-- Feedback section -->
<div class="col-12 md:col-7">
<div class="col-12 md:col-8">
<!-- Written Feedback overview -->
<div class="feedback-section mb-3">
<Title class="flex mb-3">Feedback</Title>
Expand Down

0 comments on commit 15682e9

Please sign in to comment.