<commit_before>import rest_framework_filters as filters
from rest_framework import routers

from icekit.api.base_serializers import ModelSubSerializer
from icekit.api.base_views import RedirectViewset
from icekit.api.base_filters import CaseInsensitiveBooleanFilter

from ...api_serializers import Creator
from .models import PersonCreator as PersonCreatorModel


class PersonName(ModelSubSerializer):
    class Meta:
        model = PersonCreatorModel
        source_prefix = 'name_'
        fields = (
            'name_display',
            'name_sort',
            'name_full',
            'name_given',
            'name_family',
        )


class LifeInfo(ModelSubSerializer):
    class Meta:
        model = PersonCreatorModel
        source_prefix = 'life_info_'
        fields = (
            'life_info_birth_date_display',
            'life_info_birth_date_edtf',
            'life_info_birth_place',
            'life_info_birth_place_historic',
            'life_info_death_date_display',
            'life_info_death_date_edtf',
            'life_info_death_place',
        )


class Background(ModelSubSerializer):
    class Meta:
        model = PersonCreatorModel
        source_prefix = 'background_'
        fields = (
            'background_ethnicity',
            'background_nationality',
            'background_neighborhood',
            'background_city',
            'background_state_province',
            'background_country',
            'background_continent',
        )


class Person(Creator):
    name = PersonName(help_text="Parts and forms of the Artist's name")
    life_info = LifeInfo(help_text="Birth and death dates and places")
    background = Background(help_text="Ethnicity, nationality and culture")

    class Meta:
        model = PersonCreatorModel
        fields = Creator.Meta.fields + (
            'name',
            'life_info',
            'background',
        )
        extra_kwargs = Creator.Meta.extra_kwargs


class APIViewSet(RedirectViewset):
    """
    Artist resource.
    """
    queryset = PersonCreatorModel.objects.all()
    serializer_class = Person
    ordering_fields = (
            'name_display',
            'name_sort',
            'name_given',
            'name_family',
            'background_country',
            'background_continent',
    )


router = routers.DefaultRouter()
router.register('person', APIViewSet, 'person')<commit_msg>Fix URL reverse name and extra imports in Person API<commit_after>from rest_framework import routers

from icekit.api.base_serializers import ModelSubSerializer
from icekit.api.base_views import RedirectViewset

from ...api_serializers import Creator
from .models import PersonCreator as PersonCreatorModel


class PersonName(ModelSubSerializer):
    class Meta:
        model = PersonCreatorModel
        source_prefix = 'name_'
        fields = (
            'name_display',
            'name_sort',
            'name_full',
            'name_given',
            'name_family',
        )


class LifeInfo(ModelSubSerializer):
    class Meta:
        model = PersonCreatorModel
        source_prefix = 'life_info_'
        fields = (
            'life_info_birth_date_display',
            'life_info_birth_date_edtf',
            'life_info_birth_place',
            'life_info_birth_place_historic',
            'life_info_death_date_display',
            'life_info_death_date_edtf',
            'life_info_death_place',
        )


class Background(ModelSubSerializer):
    class Meta:
        model = PersonCreatorModel
        source_prefix = 'background_'
        fields = (
            'background_ethnicity',
            'background_nationality',
            'background_neighborhood',
            'background_city',
            'background_state_province',
            'background_country',
            'background_continent',
        )


class Person(Creator):
    name = PersonName(help_text="Parts and forms of the Artist's name")
    life_info = LifeInfo(help_text="Birth and death dates and places")
    background = Background(help_text="Ethnicity, nationality and culture")

    class Meta:
        model = PersonCreatorModel
        fields = Creator.Meta.fields + (
            'name',
            'life_info',
            'background',
        )
        extra_kwargs = Creator.Meta.extra_kwargs


class APIViewSet(RedirectViewset):
    """
    Artist resource.
    """
    queryset = PersonCreatorModel.objects.all()
    serializer_class = Person
    ordering_fields = (
            'name_display',
            'name_sort',
            'name_given',
            'name_family',
            'background_country',
            'background_continent',
    )


router = routers.DefaultRouter()
router.register('person', APIViewSet, 'person-api')
{'fraction_non_alphanumeric': 0.08178205396360594, 'fraction_numerical': 0.0, 'mean_word_length': 2.3463960811756475, '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': '980076', 'n_tokens_mistral': 1325, 'n_tokens_neox': 1276, 'n_words': 258}