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 15682e9 commit 4015c4e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 12 deletions.
11 changes: 2 additions & 9 deletions backend/api/permissions/submission_permissions.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
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 @@ -42,14 +41,8 @@ class SubmissionFeedbackPermission(SubmissionPermission):
def has_permission(self, request: Request, view: APIView) -> 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
def has_object_permission(self, request: Request, view: APIView, obj: Submission) -> bool:
return True


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.ReadOnlyModelViewSet):
class FeedbackViewSet(viewsets.ModelViewSet):
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-12 md:col-4">
<div class="col-6 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-8">
<div class="col-12 md:col-7">
<!-- Written Feedback overview -->
<div class="feedback-section mb-3">
<Title class="flex mb-3">Feedback</Title>
Expand Down

0 comments on commit 4015c4e

Please sign in to comment.