From 8c5e8206cd291410a2a8d714ab28dacad60ac945 Mon Sep 17 00:00:00 2001 From: Gabriel von Heijne Date: Mon, 12 Nov 2012 17:51:17 +0100 Subject: [PATCH] [Fix #124] Inline primary_location data for Project and Organisation in the API Add the data for the primary_location as full inline data in the project and organisation API resources by default. --- akvo/api/resources.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/akvo/api/resources.py b/akvo/api/resources.py index acc490ad04..782a52c14f 100644 --- a/akvo/api/resources.py +++ b/akvo/api/resources.py @@ -267,12 +267,13 @@ class Meta: class OrganisationResource(ConditionalFullResource): - partnerships = ConditionalFullToManyField( + partnerships = ConditionalFullToManyField( 'akvo.api.resources.PartnershipResource', 'partnerships', help_text='Show the projects the organisation is related to and how.' ) - locations = ConditionalFullToManyField('akvo.api.resources.OrganisationLocationResource', 'locations') + locations = ConditionalFullToManyField('akvo.api.resources.OrganisationLocationResource', 'locations') + primary_location = fields.ToOneField('akvo.api.resources.OrganisationLocationResource', 'primary_location', full=True) class Meta: allowed_methods = ['get'] @@ -341,6 +342,7 @@ class ProjectResource(ConditionalFullResource): links = ConditionalFullToManyField('akvo.api.resources.LinkResource', 'links') locations = ConditionalFullToManyField('akvo.api.resources.ProjectLocationResource', 'locations') partnerships = ConditionalFullToManyField('akvo.api.resources.PartnershipResource', 'partnerships',) + primary_location = fields.ToOneField('akvo.api.resources.ProjectLocationResource', 'primary_location', full=True) project_comments = ConditionalFullToManyField('akvo.api.resources.ProjectCommentResource', 'comments') project_updates = ConditionalFullToManyField('akvo.api.resources.ProjectUpdateResource', 'project_updates')