<commit_before>from django.contrib.auth.models import User, Group
from .models import Source, Registration
import phonenumbers
from rest_framework import serializers
from rest_framework.validators import UniqueValidator
from rest_hooks.models import Hook

from ndoh_hub import utils
from registrations import validators


class UserSerializer(serializers.HyperlinkedModelSerializer):
    class Meta:
        model = User
        fields = ('url', 'username', 'email', 'groups')


class CreateUserSerializer(serializers.Serializer):
    email = serializers.EmailField()


class GroupSerializer(serializers.HyperlinkedModelSerializer):
    class Meta:
        model = Group
        fields = ('url', 'name')


class SourceSerializer(serializers.HyperlinkedModelSerializer):

    class Meta:
        model = Source
        read_only_fields = ('created_at', 'updated_at')
        fields = ('url', 'id', 'name', 'user', 'authority', 'created_at',
                  'updated_at')


class RegistrationSerializer(serializers.ModelSerializer):

    class Meta:
        model = Registration
        read_only_fields = ('validated', 'created_by', 'updated_by',
                            'created_at', 'updated_at')
        fields = ('id', 'reg_type', 'registrant_id', 'validated', 'data',
                  'source', 'created_at', 'updated_at', 'created_by',
                  'updated_by')


class HookSerializer(serializers.ModelSerializer):

    class Meta:
        model = Hook
        read_only_fields = ('user',)
        exclude = ()


class ThirdPartyRegistrationSerializer(serializers.Serializer):
    hcw_msisdn = serializers.CharField()
    mom_msisdn = serializers.CharField()
    mom_id_type = serializers.CharField()
    mom_passport_origin = serializers.CharField(allow_null=True)
    mom_lang = serializers.CharField()
    mom_edd = serializers.CharField()
    mom_id_no = serializers.CharField()<commit_msg>Add `external_id` to Registration serializer<commit_after>from django.contrib.auth.models import User, Group
from .models import Source, Registration
import phonenumbers
from rest_framework import serializers
from rest_framework.validators import UniqueValidator
from rest_hooks.models import Hook

from ndoh_hub import utils
from registrations import validators


class UserSerializer(serializers.HyperlinkedModelSerializer):
    class Meta:
        model = User
        fields = ('url', 'username', 'email', 'groups')


class CreateUserSerializer(serializers.Serializer):
    email = serializers.EmailField()


class GroupSerializer(serializers.HyperlinkedModelSerializer):
    class Meta:
        model = Group
        fields = ('url', 'name')


class SourceSerializer(serializers.HyperlinkedModelSerializer):

    class Meta:
        model = Source
        read_only_fields = ('created_at', 'updated_at')
        fields = ('url', 'id', 'name', 'user', 'authority', 'created_at',
                  'updated_at')


class RegistrationSerializer(serializers.ModelSerializer):

    class Meta:
        model = Registration
        read_only_fields = ('validated', 'created_by', 'updated_by',
                            'created_at', 'updated_at')
        fields = ('id', 'external_id', 'reg_type', 'registrant_id',
                  'validated', 'data', 'source', 'created_at', 'updated_at',
                  'created_by', 'updated_by')


class HookSerializer(serializers.ModelSerializer):

    class Meta:
        model = Hook
        read_only_fields = ('user',)
        exclude = ()


class ThirdPartyRegistrationSerializer(serializers.Serializer):
    hcw_msisdn = serializers.CharField()
    mom_msisdn = serializers.CharField()
    mom_id_type = serializers.CharField()
    mom_passport_origin = serializers.CharField(allow_null=True)
    mom_lang = serializers.CharField()
    mom_edd = serializers.CharField()
    mom_id_no = serializers.CharField()
{'fraction_non_alphanumeric': 0.10103359173126615, 'fraction_numerical': 0.0, 'mean_word_length': 3.5864928909952605, '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': '1049714', 'n_tokens_mistral': 1086, 'n_tokens_neox': 1042, 'n_words': 246}