Commit 03e2b3e3 authored by Nicolas Joyard's avatar Nicolas Joyard

Update API

parent 5bdee8f1
......@@ -51,7 +51,8 @@ class DossierViewSet(viewsets.ReadOnlyModelViewSet):
def retrieve(self, request, pk=None):
self.serializer_class = DossierDetailSerializer
self.queryset = self.queryset.prefetch_related('proposals')
self.queryset = self.queryset.prefetch_related('proposals',
'documents')
return super(DossierViewSet, self).retrieve(request, pk)
......
......@@ -46,6 +46,19 @@ class ProposalDetailSerializer(ProposalSerializer):
fields = ProposalSerializer.Meta.fields + ('votes',)
class DocumentSerializer(serializers.HyperlinkedModelSerializer):
""" Base document serializer """
class Meta:
model = models.Document
fields = (
'dossier',
'chamber',
'kind',
'link'
)
class DossierSerializer(serializers.HyperlinkedModelSerializer):
""" Base dossier serializer """
......@@ -55,7 +68,6 @@ class DossierSerializer(serializers.HyperlinkedModelSerializer):
'title',
'reference',
'text',
'link',
'url',
)
......@@ -66,7 +78,8 @@ class DossierDetailSerializer(DossierSerializer):
"""
proposals = ProposalSerializer(many=True)
documents = DocumentSerializer(many=True)
class Meta:
model = models.Dossier
field = DossierSerializer.Meta.fields + ('proposals',)
field = DossierSerializer.Meta.fields + ('proposals', 'documents')
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment