<commit_before>from django.contrib.auth.models import User

from rest_framework import serializers

from slides_manager.models import Case, Slide, \
    SlideQualityControl


class CaseSerializer(serializers.ModelSerializer):
    slides = serializers.StringRelatedField(many=True, read_only=True)

    class Meta:
        model = Case

        fields = ('id', 'import_date', 'slides')
        read_only_fields = ('import_date', 'slides')


class SlideSerializer(serializers.ModelSerializer):

    class Meta:
        model = Slide

        fields = ('id', 'case', 'import_date', 'omero_id',
                  'image_type', 'image_microns_per_pixel', 'staining')
        read_only_fields = ('import_date',)


class SlideQualityControlSerializer(serializers.ModelSerializer):
    reviewer = serializers.SlugRelatedField(
        slug_field='username',
        queryset=User.objects.all(),
    )
    slide = serializers.PrimaryKeyRelatedField(
        write_only=True,
        queryset=Slide.objects.all(),
    )

    class Meta:
        model = SlideQualityControl

        fields = ('slide', 'rois_annotation_step', 'adequate_slide', 'not_adequacy_reason',
                  'reviewer', 'acquisition_date', 'notes')
        read_only_fields = ('acquisition_date',)
        write_only_fields = ('rois_annotation_step',)


class CaseDetailedSerializer(serializers.ModelSerializer):
    slides = SlideSerializer(many=True, read_only=True)

    class Meta:
        model = Case

        fields = ('id', 'import_date', 'slides')
        read_only_fields = ('import_date',)


class SlideDetailSerializer(serializers.ModelSerializer):
    case = serializers.PrimaryKeyRelatedField(read_only=True)
    quality_control = SlideQualityControlSerializer(read_only=True,
                                                    source='quality_control_passed')

    class Meta:
        model = Slide

        fields = ('id', 'case', 'import_date', 'omero_id',
                  'image_type', 'quality_control',
                  'image_microns_per_pixel', 'staining')
        read_only_fields = ('import_date',)

<commit_msg>updated quality control and slide serializers<commit_after>from django.contrib.auth.models import User

from rest_framework import serializers

from slides_manager.models import Case, Slide, \
    SlideQualityControl
from reviews_manager.models import ROIsAnnotationStep


class CaseSerializer(serializers.ModelSerializer):
    slides = serializers.StringRelatedField(many=True, read_only=True)

    class Meta:
        model = Case

        fields = ('id', 'import_date', 'slides')
        read_only_fields = ('import_date', 'slides')


class SlideSerializer(serializers.ModelSerializer):

    class Meta:
        model = Slide

        fields = ('id', 'case', 'import_date', 'omero_id',
                  'image_type', 'image_microns_per_pixel', 'staining')
        read_only_fields = ('import_date',)


class SlideQualityControlSerializer(serializers.ModelSerializer):
    reviewer = serializers.SlugRelatedField(
        slug_field='username',
        queryset=User.objects.all(),
    )
    slide = serializers.PrimaryKeyRelatedField(
        write_only=True,
        queryset=Slide.objects.all(),
    )
    rois_annotation_step = serializers.PrimaryKeyRelatedField(
        write_only=True,
        queryset=ROIsAnnotationStep.objects.all()
    )

    class Meta:
        model = SlideQualityControl

        fields = ('slide', 'rois_annotation_step', 'adequate_slide', 'not_adequacy_reason',
                  'reviewer', 'acquisition_date', 'notes')
        read_only_fields = ('acquisition_date',)


class CaseDetailedSerializer(serializers.ModelSerializer):
    slides = SlideSerializer(many=True, read_only=True)

    class Meta:
        model = Case

        fields = ('id', 'import_date', 'slides')
        read_only_fields = ('import_date',)


class SlideDetailSerializer(serializers.ModelSerializer):
    case = serializers.PrimaryKeyRelatedField(read_only=True)

    class Meta:
        model = Slide

        fields = ('id', 'case', 'import_date', 'omero_id',
                  'image_type', 'image_microns_per_pixel', 'staining')
        read_only_fields = ('import_date',)


{'fraction_non_alphanumeric': 0.10552644116245831, 'fraction_numerical': 0.0, 'mean_word_length': 3.2672764227642275, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1543059', 'n_tokens_mistral': 1242, 'n_tokens_neox': 1184, 'n_words': 225}