from rest_framework import serializers
from apps.system.serializers import FileSimpleSerializer
from .models import Standard, TestItem

class StandardCreateUpdateSerializer(serializers.ModelSerializer):
    class Meta:
        model = Standard
        fields = ['name', 'file', 'enabled', 'number']

class StandardSerializer(serializers.ModelSerializer):
    file_ = FileSimpleSerializer(source='file', read_only=True)
    class Meta:
        model = Standard
        fields = '__all__'

class StandardSimpleSerializer(serializers.ModelSerializer):
    class Meta:
        model = Standard
        fields = ['id', 'name', 'number']

class TestItemCreateUpdateSerializer(serializers.ModelSerializer):
    class Meta:
        model = TestItem
        fields = ['name', 'standard', 'term_number']

class TestItemSerializer(serializers.ModelSerializer):
    standard_ = StandardSimpleSerializer(source='standard', read_only=True)
    class Meta:
        model = TestItem
        fields = '__all__'

class AnalysisItemSerializer(serializers.ModelSerializer):
    pass
