<commit_before>from rest_framework import serializers

from maker.models import Maker
from folder.serializers import FolderExtendedSerializer


class RegistrationRequestSerializer(serializers.Serializer):

    email = serializers.EmailField(required=True)
    password = serializers.CharField(required=True)
    first_name = serializers.CharField(required=True)
    last_name = serializers.CharField(required=True)


class AuthenticationResponseSerializer(serializers.Serializer):

    token = serializers.CharField()


class AuthenticationRequestSerializer(serializers.Serializer):

    identifier = serializers.CharField(required=True)
    password = serializers.CharField(required=True)


class ResetPasswordRequestSerializer(serializers.Serializer):

    email = serializers.EmailField(required=True)


class ResetPasswordProcessSerializer(serializers.Serializer):

    token = serializers.CharField(required=True)
    new_password = serializers.CharField(required=True)
    confirm_password = serializers.CharField(required=True)

    def validate(self, attrs):
        if attrs['new_password'] != attrs['confirm_password']:
            raise serializers.ValidationError("'new_password' and 'confirm_password' do not match")
        return attrs


class ChangePasswordSerializer(serializers.Serializer):

    new_password = serializers.CharField(required=True)
    confirm_password = serializers.CharField(required=True)

    def validate(self, attrs):
        if attrs['new_password'] != attrs['confirm_password']:
            raise serializers.ValidationError("'new_password' and 'confirm_password' do not match")
        return attrs


class EmailChangeRequestSerializer(serializers.Serializer):

    new_email = serializers.EmailField(required=True)


class EmailChangeProcessSerializer(serializers.Serializer):

    token = serializers.CharField(required=True)


class MakerSerializer(serializers.ModelSerializer):

    class Meta:
        model = Maker
        fields = ('identifier', 'first_name', 'last_name', 'email',
                    'photo_url', 'bio', 'joined')
        read_only_fields = ('identifier', 'email', 'joined',)


class MakerProfileSerializer(serializers.ModelSerializer):

    folders = serializers.SerializerMethodField('public_folders')

    class Meta:
        model = Maker
        fields = ('identifier', 'first_name', 'last_name', 'email',
                    'photo_url', 'folders', 'bio', 'joined')

    def public_folders(self, obj):
        query_set = obj.folders.filter(is_public=True)
        serializer = FolderExtendedSerializer(instance=query_set, many=True)
        return serializer.data<commit_msg>Space<commit_after>from rest_framework import serializers

from maker.models import Maker
from folder.serializers import FolderExtendedSerializer


class RegistrationRequestSerializer(serializers.Serializer):

    email = serializers.EmailField(required=True)
    password = serializers.CharField(required=True)
    first_name = serializers.CharField(required=True)
    last_name = serializers.CharField(required=True)


class AuthenticationResponseSerializer(serializers.Serializer):

    token = serializers.CharField()


class AuthenticationRequestSerializer(serializers.Serializer):

    identifier = serializers.CharField(required=True)
    password = serializers.CharField(required=True)


class ResetPasswordRequestSerializer(serializers.Serializer):

    email = serializers.EmailField(required=True)


class ResetPasswordProcessSerializer(serializers.Serializer):

    token = serializers.CharField(required=True)
    new_password = serializers.CharField(required=True)
    confirm_password = serializers.CharField(required=True)

    def validate(self, attrs):
        if attrs['new_password'] != attrs['confirm_password']:
            raise serializers.ValidationError("'new_password' and 'confirm_password' do not match")
        return attrs


class ChangePasswordSerializer(serializers.Serializer):

    new_password = serializers.CharField(required=True)
    confirm_password = serializers.CharField(required=True)

    def validate(self, attrs):
        if attrs['new_password'] != attrs['confirm_password']:
            raise serializers.ValidationError("'new_password' and 'confirm_password' do not match")
        return attrs


class EmailChangeRequestSerializer(serializers.Serializer):

    new_email = serializers.EmailField(required=True)


class EmailChangeProcessSerializer(serializers.Serializer):

    token = serializers.CharField(required=True)


class MakerSerializer(serializers.ModelSerializer):

    class Meta:
        model = Maker
        fields = ('id', 'identifier', 'first_name', 'last_name', 'email',
                    'photo_url', 'bio', 'joined')
        read_only_fields = ('identifier', 'email', 'joined',)


class MakerProfileSerializer(serializers.ModelSerializer):

    folders = serializers.SerializerMethodField('public_folders')

    class Meta:
        model = Maker
        fields = ('id', 'identifier', 'first_name', 'last_name', 'email',
                    'photo_url', 'folders', 'bio', 'joined')

    def public_folders(self, obj):
        query_set = obj.folders.filter(is_public=True)
        serializer = FolderExtendedSerializer(instance=query_set, many=True)
        return serializer.data
{'fraction_non_alphanumeric': 0.09728506787330317, 'fraction_numerical': 0.0, 'mean_word_length': 4.637619553666313, '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': '2457503', 'n_tokens_mistral': 1425, 'n_tokens_neox': 1372, 'n_words': 267}