Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add work_amendments to PublishedDocumentSerializer #1632

Merged
merged 3 commits into from
Nov 22, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion indigo_content_api/v2/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from cobalt import datestring

from indigo_api.models import Document, Attachment, Country, Locality, PublicationDocument, TaxonomyVocabulary
from indigo_api.models import Document, Attachment, Country, Locality, PublicationDocument, TaxonomyVocabulary, Amendment
from indigo_api.serializers import \
DocumentSerializer, AttachmentSerializer, VocabularyTopicSerializer, CommencementSerializer, \
PublicationDocumentSerializer as PublicationDocumentSerializerBase
Expand Down Expand Up @@ -68,6 +68,19 @@ def get_url(self, instance):
kwargs={'frbr_uri': uri, 'filename': instance.filename})


class AmendmentSerializer(serializers.ModelSerializer):
date = serializers.DateField(source='date')
amending_title = serializers.CharField(source='amending_work.title')
amending_uri = serializers.CharField(source='amending_work.frbr_uri')

class Meta:
model = Amendment
fields = (
longhotsummer marked this conversation as resolved.
Show resolved Hide resolved
'amending_work', 'date',
)
read_only_fields = fields


class PublishedDocumentSerializer(DocumentSerializer, PublishedDocUrlMixin):
""" Serializer for published documents.

Expand All @@ -80,6 +93,7 @@ class PublishedDocumentSerializer(DocumentSerializer, PublishedDocUrlMixin):
as_at_date = serializers.DateField(source='work.as_at_date')
commenced = serializers.BooleanField(source='work.commenced')
commencements = CommencementSerializer(many=True, source='work.commencements')
work_amendments = AmendmentSerializer(many=True, source='work.amendments')
parent_work = serializers.SerializerMethodField()
custom_properties = serializers.JSONField(source='work.labeled_properties')
stub = serializers.BooleanField(source='work.stub')
Expand Down