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 all commits
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
17 changes: 15 additions & 2 deletions 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,18 @@ def get_url(self, instance):
kwargs={'frbr_uri': uri, 'filename': instance.filename})


class AmendmentSerializer(serializers.ModelSerializer):
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
'date', 'amending_title', 'amending_uri'
)
read_only_fields = fields


class PublishedDocumentSerializer(DocumentSerializer, PublishedDocUrlMixin):
""" Serializer for published documents.
Expand All @@ -80,6 +92,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 All @@ -97,7 +110,7 @@ class Meta:

'publication_date', 'publication_name', 'publication_number', 'publication_document',
'expression_date', 'commenced', 'commencement_date', 'commencements', 'assent_date',
'language', 'repeal', 'amendments', 'points_in_time', 'parent_work', 'custom_properties',
'language', 'repeal', 'amendments', 'work_amendments', 'points_in_time', 'parent_work', 'custom_properties',
'numbered_title', 'taxonomies', 'as_at_date', 'stub', 'principal', 'type_name',

'links',
Expand Down