Skip to content

Commit 810c2b0

Browse files
authored
fix: Add author field to ContentSerializer for Forums V2 API compatibility (#245)
The Forums V2 API responses were missing the 'author' attribute that is expected by the frontend, causing issues when displaying comment/thread author information. Analysis showed that: - The ContentSerializer already has 'username' field mapped to 'author_username' - Frontend expects an 'author' field in addition to 'username' - Both should reference the same source data (author_username) This change adds the 'author' field to the DRF serializer, mapped to the same 'author_username' source as 'username', maintaining backward compatibility while fixing the missing field issue. Fixes compatibility issues with Forums V2 API responses.
1 parent fb17be3 commit 810c2b0

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

forum/serializers/contents.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ class ContentSerializer(serializers.Serializer[dict[str, Any]]):
6767
at_position_list = serializers.ListField(default=[])
6868
user_id = serializers.CharField(source="author_id")
6969
username = serializers.CharField(source="author_username", allow_null=True)
70+
author = serializers.CharField(
71+
source="author_username", allow_null=True, required=False
72+
)
7073
commentable_id = serializers.CharField(default="course")
7174
votes = VoteSummarySerializer()
7275
abuse_flaggers = serializers.ListField(child=serializers.CharField(), default=[])

0 commit comments

Comments
 (0)