from apps.wpmw.models import Wpr, WprDefect
from apps.utils.serializers import CustomModelSerializer
from rest_framework import serializers

class WprDefectSerializer(CustomModelSerializer):
    defect_name = serializers.CharField(source="defect.name", read_only=True)

    class Meta:
        model = WprDefect
        fields = "__all__"


class WprSerializer(CustomModelSerializer):
    material_name = serializers.StringRelatedField(
        source='material', read_only=True) 
    wprdefect = WprDefectSerializer(many=True, read_only=True)  

    class Meta:
        model = Wpr
        fields = '__all__'