Return email instead of id in document_requests list view

This commit is contained in:
Keannu Bernasol 2024-11-24 23:53:44 +08:00
parent 7a29e0b737
commit 9198867346

View file

@ -24,7 +24,8 @@ class DocumentRequestCreationSerializer(serializers.ModelSerializer):
documents = DocumentRequestUnitCreationSerializer(many=True, required=True) documents = DocumentRequestUnitCreationSerializer(many=True, required=True)
college = serializers.CharField(max_length=64) college = serializers.CharField(max_length=64)
purpose = serializers.CharField(max_length=512) purpose = serializers.CharField(max_length=512)
type = serializers.ChoiceField(choices=DocumentRequest.TYPE_CHOICES, required=True) type = serializers.ChoiceField(
choices=DocumentRequest.TYPE_CHOICES, required=True)
class Meta: class Meta:
model = DocumentRequest model = DocumentRequest
@ -73,6 +74,9 @@ class DocumentRequestUnitWithFileSerializer(serializers.ModelSerializer):
class DocumentRequestSerializer(serializers.ModelSerializer): class DocumentRequestSerializer(serializers.ModelSerializer):
documents = serializers.SerializerMethodField() documents = serializers.SerializerMethodField()
requester = serializers.SlugRelatedField(
many=False, slug_field="email", queryset=CustomUser.objects.all(), required=False
)
purpose = serializers.CharField(max_length=512) purpose = serializers.CharField(max_length=512)
date_requested = serializers.DateTimeField( date_requested = serializers.DateTimeField(
format="%m-%d-%Y %I:%M %p", read_only=True format="%m-%d-%Y %I:%M %p", read_only=True