<commit_before>from models import *
from rest_framework import serializers


class RatingSerializer(serializers.ModelSerializer):
    class Meta:
        model = Rating
        fields = ('id', 'name', 'desc', 'desc_class', 'rank', 'colour')


class AttributeSerializer(serializers.ModelSerializer):
    ratings = RatingSerializer(many=True, read_only=True)

    class Meta:
        model = Attribute
        fields = ('id', 'name', 'desc', 'desc_class', 'rank', 'ratings')


class TemplateSerializer(serializers.ModelSerializer):
    attributes = AttributeSerializer(many=True, read_only=True)

    class Meta:
        model = Template
        fields = ('id', 'name', 'short_desc', 'taggable', 'attributes')


class TemplateSimpleSerializer(serializers.ModelSerializer):

    class Meta:
        model = Template
        # fields = ('id', 'name', 'short_desc')


class TagSerializer(serializers.ModelSerializer):

    class Meta:
        model = Tag
        fields = ('id', 'name')


class MeasurementSerializer(serializers.ModelSerializer):
    class Meta:
        model = Measurement
        fields = ('id', 'created', 'updated', 'assessment', 'rating', 'target_rating', 'observations', 'action')
        depth = 1


class MeasurementCreateSerializer(serializers.ModelSerializer):
    assessment = serializers.PrimaryKeyRelatedField(queryset=Assessment.objects.all())
    rating = serializers.PrimaryKeyRelatedField(queryset=Rating.objects.all())
    target_rating = serializers.PrimaryKeyRelatedField(
        allow_null=True,
        queryset=Rating.objects.all(),
        required=False
    )
    observations = serializers.CharField(allow_null=True, allow_blank=True)
    action = serializers.CharField(allow_null=True, allow_blank=True)

    class Meta:
        model = Measurement
        fields = ('id', 'created', 'updated', 'assessment', 'rating', 'target_rating', 'observations', 'action')


class AssessmentSerializer(serializers.ModelSerializer):
    class Meta:
        model = Assessment
        depth = 2


class AssessmentCreateSerializer(serializers.ModelSerializer):
    template = serializers.PrimaryKeyRelatedField(queryset=Template.objects.all())
    team = serializers.PrimaryKeyRelatedField(queryset=Team.objects.all())
    tags = serializers.PrimaryKeyRelatedField(many=True, allow_null=True, queryset=Tag.objects.all())

    class Meta:
        model = Assessment
        fields = ('id', 'created', 'updated', 'template', 'tags', 'status', 'team')


class AssessmentSimpleSerializer(serializers.ModelSerializer):
<commit_msg>allow updating the tags on an assessment<commit_after>from models import *
from rest_framework import serializers


class RatingSerializer(serializers.ModelSerializer):
    class Meta:
        model = Rating
        fields = ('id', 'name', 'desc', 'desc_class', 'rank', 'colour')


class AttributeSerializer(serializers.ModelSerializer):
    ratings = RatingSerializer(many=True, read_only=True)

    class Meta:
        model = Attribute
        fields = ('id', 'name', 'desc', 'desc_class', 'rank', 'ratings')


class TemplateSerializer(serializers.ModelSerializer):
    attributes = AttributeSerializer(many=True, read_only=True)

    class Meta:
        model = Template
        fields = ('id', 'name', 'short_desc', 'taggable', 'attributes')


class TemplateSimpleSerializer(serializers.ModelSerializer):

    class Meta:
        model = Template
        # fields = ('id', 'name', 'short_desc')


class TagSerializer(serializers.ModelSerializer):

    class Meta:
        model = Tag
        fields = ('id', 'name')


class MeasurementSerializer(serializers.ModelSerializer):
    class Meta:
        model = Measurement
        fields = ('id', 'created', 'updated', 'assessment', 'rating', 'target_rating', 'observations', 'action')
        depth = 1


class MeasurementCreateSerializer(serializers.ModelSerializer):
    assessment = serializers.PrimaryKeyRelatedField(queryset=Assessment.objects.all())
    rating = serializers.PrimaryKeyRelatedField(queryset=Rating.objects.all())
    target_rating = serializers.PrimaryKeyRelatedField(
        allow_null=True,
        queryset=Rating.objects.all(),
        required=False
    )
    observations = serializers.CharField(allow_null=True, allow_blank=True)
    action = serializers.CharField(allow_null=True, allow_blank=True)

    class Meta:
        model = Measurement
        fields = ('id', 'created', 'updated', 'assessment', 'rating', 'target_rating', 'observations', 'action')


class AssessmentSerializer(serializers.ModelSerializer):
    tags = serializers.PrimaryKeyRelatedField(many=True, allow_null=True, queryset=Tag.objects.all())

    class Meta:
        model = Assessment
        depth = 2


class AssessmentCreateSerializer(serializers.ModelSerializer):
    template = serializers.PrimaryKeyRelatedField(queryset=Template.objects.all())
    team = serializers.PrimaryKeyRelatedField(queryset=Team.objects.all())
    tags = serializers.PrimaryKeyRelatedField(many=True, allow_null=True, queryset=Tag.objects.all())

    class Meta:
        model = Assessment
        fields = ('id', 'created', 'updated', 'template', 'tags', 'status', 'team')


class AssessmentSimpleSerializer(serializers.ModelSerializer):

{'fraction_non_alphanumeric': 0.11864730607565915, 'fraction_numerical': 0.0007642338555598013, 'mean_word_length': 4.203777335984095, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4122322', 'n_tokens_mistral': 1454, 'n_tokens_neox': 1377, 'n_words': 308}