fix(pre-existing): FUser has no nickname field - use first_name (article notify, message sender_name, bug user_name)

This commit is contained in:
async-upgrade
2026-09-06 16:43:20 +08:00
parent d6e39ab976
commit e3d057dd54
3 changed files with 11 additions and 11 deletions
+8 -8
View File
@@ -1,4 +1,4 @@
from adrf.serializers import (
from adrf.serializers import (
ModelSerializer, CharField, ImageField, DateTimeField,
ListField, FileField, SerializerMethodField,
)
@@ -34,7 +34,7 @@ class BugReportCommentAttachmentSerializer(ModelSerializer):
class BugReportCommentSerializer(ModelSerializer):
user_name = CharField(source='user.nickname', read_only=True)
user_name = CharField(source='user.first_name', read_only=True)
user_avatar = ImageField(source='user.avatar', read_only=True)
images = BugReportCommentImageSerializer(many=True, read_only=True)
attachments = BugReportCommentAttachmentSerializer(many=True, read_only=True)
@@ -50,7 +50,7 @@ class BugReportCommentSerializer(ModelSerializer):
class BugReportListSerializer(ModelSerializer):
user_name = CharField(source='user.nickname', read_only=True)
user_name = CharField(source='user.first_name', read_only=True)
images_count = SerializerMethodField()
class Meta:
@@ -65,7 +65,7 @@ class BugReportListSerializer(ModelSerializer):
class BugReportDetailSerializer(ModelSerializer):
user_name = CharField(source='user.nickname', read_only=True)
user_name = CharField(source='user.first_name', read_only=True)
user_avatar = ImageField(source='user.avatar', read_only=True)
images = BugReportImageSerializer(many=True, read_only=True)
attachments = BugReportAttachmentSerializer(many=True, read_only=True)
@@ -102,14 +102,14 @@ class BugReportCreateSerializer(ModelSerializer):
max_size = 10 * 1024 * 1024 # 10MB
for image in value:
if image.size > max_size:
raise ValidationError(f"图片 {image.name} 大小超过10MB限制")
raise ValidationError(f"鍥剧墖 {image.name} 澶у皬瓒呰繃10MB闄愬埗")
return value
def validate_attachments(self, value):
max_size = 20 * 1024 * 1024 # 20MB
for attachment in value:
if attachment.size > max_size:
raise ValidationError(f"附件 {attachment.name} 大小超过20MB限制")
raise ValidationError(f"闄勪欢 {attachment.name} 澶у皬瓒呰繃20MB闄愬埗")
return value
async def acreate(self, validated_data):
@@ -152,14 +152,14 @@ class BugReportCommentCreateSerializer(ModelSerializer):
max_size = 10 * 1024 * 1024 # 10MB
for image in value:
if image.size > max_size:
raise ValidationError(f"图片 {image.name} 大小超过10MB限制")
raise ValidationError(f"鍥剧墖 {image.name} 澶у皬瓒呰繃10MB闄愬埗")
return value
def validate_attachments(self, value):
max_size = 20 * 1024 * 1024 # 20MB
for attachment in value:
if attachment.size > max_size:
raise ValidationError(f"附件 {attachment.name} 大小超过20MB限制")
raise ValidationError(f"闄勪欢 {attachment.name} 澶у皬瓒呰繃20MB闄愬埗")
return value
async def acreate(self, validated_data):