Skip to content
Snippets Groups Projects

Resolve "Changing feedback that a reviewer worken on is forbidden after set to final"

All threads resolved!
1 file
+ 1
1
Compare changes
  • Side-by-side
  • Inline
@@ -7,7 +7,7 @@ from rest_framework import serializers
from rest_framework.utils import html
from core import models
from core.models import Feedback
from core.models import Feedback, UserAccount
from util.factories import GradyUserFactory
from .generic import DynamicFieldsModelSerializer
@@ -121,8 +121,12 @@ class FeedbackSerializer(DynamicFieldsModelSerializer):
submission = validated_data.pop('of_submission')
feedback_lines = validated_data.pop('feedback_lines', [])
labels = validated_data.pop('labels', [])
user = self.context['request'].user
feedback = Feedback.objects.create(of_submission=submission,
**validated_data)
if user.role == UserAccount.REVIEWER:
feedback.final_by_reviewer = self.context['request'].data['is_final']
for label in labels:
feedback.labels.add(label)
@@ -141,6 +145,11 @@ class FeedbackSerializer(DynamicFieldsModelSerializer):
@transaction.atomic
def update(self, feedback, validated_data):
user = self.context['request'].user
if user.role == UserAccount.REVIEWER:
feedback.final_by_reviewer = self.context['request'].data['is_final']
for comment in validated_data.pop('feedback_lines', []):
labels = comment.pop('labels', [])
comment_instance, _ = models.FeedbackComment.objects.update_or_create(
Loading