Skip to content

Commit

Permalink
fixes #332 - include full page data in maps api
Browse files Browse the repository at this point in the history
  • Loading branch information
groovecoder committed Mar 26, 2013
1 parent d963ba2 commit b87b02a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
8 changes: 8 additions & 0 deletions docs/source/api.rst
Expand Up @@ -333,6 +333,14 @@ List

/api/map/

Parameters
__________

full

* `False`: (default) pages for maps are returned as links
* `True`: pages for maps are returned in full (see `Pages`_ example object)

Fetch
~~~~~

Expand Down
2 changes: 1 addition & 1 deletion sapling/maps/api.py
Expand Up @@ -11,7 +11,7 @@


class MapResource(pages.api.PageURLMixin, gis_resources.ModelResource):
page = fields.ToOneField('pages.api.PageResource', 'page')
page = fields.ToOneField('pages.api.PageResource', 'page', full=True)

class Meta:
queryset = MapData.objects.all()
Expand Down
5 changes: 5 additions & 0 deletions sapling/pages/api.py
Expand Up @@ -167,6 +167,11 @@ def get_search(self, request, **kwargs):
self.log_throttled_access(request)
return self.create_response(request, object_list)

def dehydrate(self, bundle):
if not bundle.request.GET.get('full'):
bundle = bundle.data['resource_uri']
return bundle


# We don't use the PageURLMixin approach here because it becomes
# too complicated to generate pretty URLs with the historical version
Expand Down

0 comments on commit b87b02a

Please sign in to comment.