diff --git a/cl/api/urls.py b/cl/api/urls.py index 7b07896761..34234499f8 100644 --- a/cl/api/urls.py +++ b/cl/api/urls.py @@ -29,7 +29,6 @@ urlpatterns = [ - # url(r'^api/rest/(?P[v3]+)/', include(router.urls)), url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')), url(r'^api/rest/(?P[v3]+)/', include(router.urls)), diff --git a/cl/people_db/api_serializers.py b/cl/people_db/api_serializers.py index c6691c7cea..9e7aa3728c 100644 --- a/cl/people_db/api_serializers.py +++ b/cl/people_db/api_serializers.py @@ -3,10 +3,17 @@ from cl.api.utils import DynamicFieldsModelSerializer from cl.people_db.models import Person, Position, RetentionEvent, \ Education, School, PoliticalAffiliation, Source, ABARating +from cl.search.api_serializers import CourtSerializer class SchoolSerializer(DynamicFieldsModelSerializer, serializers.HyperlinkedModelSerializer): + is_alias_of = serializers.HyperlinkedRelatedField( + many=False, + view_name='school-detail', + read_only=True + ) + class Meta: model = School @@ -14,6 +21,11 @@ class Meta: class EducationSerializer(DynamicFieldsModelSerializer, serializers.HyperlinkedModelSerializer): school = SchoolSerializer(many=False, read_only=True) + person = serializers.HyperlinkedRelatedField( + many=False, + view_name='person-detail', + read_only=True, + ) class Meta: model = Education @@ -21,18 +33,36 @@ class Meta: class PoliticalAffiliationSerializer(DynamicFieldsModelSerializer, serializers.HyperlinkedModelSerializer): + person = serializers.HyperlinkedRelatedField( + many=False, + view_name='person-detail', + read_only=True, + ) + class Meta: model = PoliticalAffiliation class SourceSerializer(DynamicFieldsModelSerializer, serializers.HyperlinkedModelSerializer): + person = serializers.HyperlinkedRelatedField( + many=False, + view_name='person-detail', + read_only=True, + ) + class Meta: model = Source class ABARatingSerializer(DynamicFieldsModelSerializer, serializers.HyperlinkedModelSerializer): + person = serializers.HyperlinkedRelatedField( + many=False, + view_name='person-detail', + read_only=True, + ) + class Meta: model = ABARating @@ -40,16 +70,23 @@ class Meta: class PersonSerializer(DynamicFieldsModelSerializer, serializers.HyperlinkedModelSerializer): race = serializers.StringRelatedField(many=True) + sources = SourceSerializer(many=True, read_only=True) + aba_ratings = ABARatingSerializer(many=True, read_only=True) + educations = EducationSerializer(many=True, read_only=True) positions = serializers.HyperlinkedRelatedField( many=True, view_name='position-detail', read_only=True, ) - educations = EducationSerializer(many=True, read_only=True) - political_affiliations = PoliticalAffiliationSerializer(many=True, - read_only=True) - sources = SourceSerializer(many=True, read_only=True) - aba_ratings = ABARatingSerializer(many=True, read_only=True) + political_affiliations = PoliticalAffiliationSerializer( + many=True, + read_only=True + ) + is_alias_of = serializers.HyperlinkedRelatedField( + many=False, + view_name='person-detail', + read_only=True + ) class Meta: model = Person @@ -57,14 +94,26 @@ class Meta: class RetentionEventSerializer(DynamicFieldsModelSerializer, serializers.HyperlinkedModelSerializer): + position = serializers.HyperlinkedRelatedField( + many=False, + view_name='position-detail', + read_only=True, + ) + class Meta: model = RetentionEvent class PositionSerializer(DynamicFieldsModelSerializer, serializers.HyperlinkedModelSerializer): - appointer = PersonSerializer(many=False, read_only=True) retention_events = RetentionEventSerializer(many=True, read_only=True) + person = PersonSerializer(many=False, read_only=True) + appointer = PersonSerializer(many=False, read_only=True) + supervisor = PersonSerializer(many=False, read_only=True) + predecessor = PersonSerializer(many=False, read_only=True) + school = SchoolSerializer(many=False, read_only=True) + court = CourtSerializer(many=False, read_only=True) + # TODO: add clerks class Meta: