Skip to content

Commit 9fab13a

Browse files
Simplify createdBy
1 parent f3a4f46 commit 9fab13a

1 file changed

Lines changed: 4 additions & 10 deletions

File tree

backend/annotation/serializers.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from django.contrib.auth.models import AnonymousUser
44

55
from annotation.models import (
6+
BaseAnnotation,
67
KnowledgeBaseAnnotation,
78
Label,
89
LabelAnnotation,
@@ -46,16 +47,9 @@ def get_removable(self, annotation) -> bool:
4647
raise NotImplementedError("Subclasses must implement get_removable method.")
4748

4849
def get_createdBy(self, annotation) -> str | None:
49-
"""
50-
Return the full name of the user who created the annotation or a
51-
default string if not available.
52-
"""
53-
default = "unknown user"
54-
if annotation.created_by is None:
55-
return default
56-
57-
created_by_name = f"{annotation.created_by.first_name} {annotation.created_by.last_name}".strip()
58-
return created_by_name if created_by_name else default
50+
"""Returns the full name of the user who created the annotation."""
51+
return annotation.created_by.get_full_name()
52+
5953

6054

6155
class KnowledgeBaseAnnotationSerializer(AnnotationBaseSerializer):

0 commit comments

Comments
 (0)