diff --git a/backend/annotation/serializers.py b/backend/annotation/serializers.py index 3f253165..0974abbd 100644 --- a/backend/annotation/serializers.py +++ b/backend/annotation/serializers.py @@ -17,12 +17,14 @@ class AnnotationBaseSerializer(serializers.ModelSerializer): """ createdAt = serializers.DateTimeField(source="created_at", read_only=True) - createdBy = serializers.SerializerMethodField(method_name="get_createdBy", read_only=True) + createdBy = serializers.SerializerMethodField( + method_name="get_created_by", read_only=True + ) removedAt = serializers.DateTimeField( source="removed_at", allow_null=True, read_only=True ) - removedBy = serializers.PrimaryKeyRelatedField( - source="removed_by", allow_null=True, read_only=True + removedBy = serializers.SerializerMethodField( + method_name="get_removed_by", allow_null=True, read_only=True ) removable = serializers.SerializerMethodField(read_only=True) @@ -45,10 +47,15 @@ def get_removable(self, annotation) -> bool: """This should be overridden in subclasses.""" raise NotImplementedError("Subclasses must implement get_removable method.") - def get_createdBy(self, annotation) -> str | None: + def get_created_by(self, annotation) -> str | None: """Returns the full name of the user who created the annotation.""" return annotation.created_by.get_full_name() + def get_removed_by(self, annotation) -> str | None: + """Returns the full name of the user who removed the annotation, or None if not removed.""" + if annotation.removed_by: + return annotation.removed_by.get_full_name() + return None class KnowledgeBaseAnnotationSerializer(AnnotationBaseSerializer): @@ -95,6 +102,7 @@ def validate_id(self, value): f"KnowledgeBaseAnnotation item with ID {value} does not exist." ) + class LabelSerializer(serializers.ModelSerializer): """ Serializer for Label model. @@ -156,6 +164,7 @@ def get_removable(self, annotation: LabelAnnotation) -> bool: return False + class SelectedLabelSerializer(serializers.Serializer): """Serializer for a selected label in the save labels input.""" diff --git a/backend/annotation/serializers_test.py b/backend/annotation/serializers_test.py index de578b5e..30cdd8be 100644 --- a/backend/annotation/serializers_test.py +++ b/backend/annotation/serializers_test.py @@ -1,7 +1,6 @@ import pytest from typing import Any -from django.utils import timezone from django.contrib.auth.models import Permission from rest_framework.test import APIRequestFactory @@ -11,7 +10,6 @@ LabelAnnotationSerializer, SaveLabelsInputSerializer, ) -from problem.serializers import ProblemSerializer @pytest.mark.django_db diff --git a/backend/problem/views/problem.py b/backend/problem/views/problem.py index e27b871e..d26b3813 100644 --- a/backend/problem/views/problem.py +++ b/backend/problem/views/problem.py @@ -96,12 +96,8 @@ def _get_problem_response(self, request: Request, pk: int | None) -> Response: serializer = self.get_serializer(problem) - kb_annotations = KnowledgeBaseAnnotation.objects.filter( - problem=problem, removed_at__isnull=True - ) - label_annotations = LabelAnnotation.objects.filter( - problem=problem, removed_at__isnull=True - ) + kb_annotations = KnowledgeBaseAnnotation.objects.filter(problem=problem) + label_annotations = LabelAnnotation.objects.filter(problem=problem) # kbAnnotations and labelAnnotations are not included in the # ProblemSerializer because they require additional context for diff --git a/frontend/src/app/annotate/annotation-comments/annotation-comments.component.html b/frontend/src/app/annotate/annotation-comments/annotation-comments.component.html index 47cddac6..c8d4c473 100644 --- a/frontend/src/app/annotate/annotation-comments/annotation-comments.component.html +++ b/frontend/src/app/annotate/annotation-comments/annotation-comments.component.html @@ -1,4 +1,112 @@ -
Loading…
+} @else { ++ No annotations match the current filters. +
+} @else { +