feat(api/2): Added some more default fields to the pages endpoint

This commit is contained in:
Karl Hobley 2015-12-04 15:31:33 +00:00
parent 40de7d9090
commit b4e6229b37
2 changed files with 16 additions and 4 deletions

View file

@ -195,7 +195,14 @@ class PagesAPIEndpoint(BaseAPIEndpoint):
'child_of',
'descendant_of',
])
extra_api_fields = ['title']
extra_api_fields = [
'title',
'slug',
'show_in_menus',
'seo_title',
'search_description',
'first_published_at',
]
name = 'pages'
model = Page

View file

@ -89,7 +89,7 @@ class TestPageListing(TestCase):
self.assertEqual(page['meta']['type'], 'demosite.BlogEntryPage')
# All fields in specific type available
self.assertEqual(set(page.keys()), {'id', 'meta', 'title', 'related_links', 'date', 'body', 'tags', 'feed_image', 'carousel_items'})
self.assertEqual(set(page.keys()), {'id', 'meta', 'title', 'slug', 'show_in_menus', 'seo_title', 'search_description', 'first_published_at', 'related_links', 'date', 'body', 'tags', 'feed_image', 'carousel_items'})
def test_type_filter_total_count(self):
response = self.get_response(type='demosite.BlogEntryPage')
@ -114,7 +114,7 @@ class TestPageListing(TestCase):
event_page_seen = True
# Only generic fields available
self.assertEqual(set(page.keys()), {'id', 'meta', 'title'})
self.assertEqual(set(page.keys()), {'id', 'meta', 'title', 'slug', 'show_in_menus', 'seo_title', 'search_description', 'first_published_at'})
self.assertTrue(blog_page_seen, "No blog pages were found in the results")
self.assertTrue(event_page_seen, "No event pages were found in the results")
@ -140,7 +140,7 @@ class TestPageListing(TestCase):
content = json.loads(response.content.decode('UTF-8'))
for page in content['results']:
self.assertEqual(set(page.keys()), {'id', 'meta', 'title', 'date', 'related_links', 'feed_image', 'body', 'carousel_items', 'tags'})
self.assertEqual(set(page.keys()), {'id', 'meta', 'title', 'slug', 'show_in_menus', 'seo_title', 'search_description', 'first_published_at', 'date', 'related_links', 'feed_image', 'body', 'carousel_items', 'tags'})
def test_fields(self):
response = self.get_response(type='demosite.BlogEntryPage', fields='title,date,feed_image')
@ -647,6 +647,11 @@ class TestPageDetail(TestCase):
'meta',
'parent',
'title',
'slug',
'show_in_menus',
'seo_title',
'search_description',
'first_published_at',
'body',
'tags',
'date',