Skip to content

Commit

Permalink
Added api fields to StandardPages
Browse files Browse the repository at this point in the history
  • Loading branch information
Ole Kristian Losvik committed Dec 4, 2019
1 parent 0dcc142 commit 39a04f1
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion website/standardpages/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
from wagtail.admin.edit_handlers import (FieldPanel, InlinePanel,
MultiFieldPanel, PageChooserPanel,
StreamFieldPanel)
from wagtail.api import APIField
from wagtail.core.fields import StreamField
from wagtail.core.models import Orderable
from wagtail.images.api.fields import ImageRenditionField
from wagtail.images.edit_handlers import ImageChooserPanel
from wagtail.search import index

from grapple.models import GraphQLStreamfield, GraphQLString
from grapple.models import GraphQLImage, GraphQLStreamfield, GraphQLString

from website.utils.blocks import StoryBlock
from website.utils.models import BasePage, RelatedPage
Expand Down Expand Up @@ -62,9 +64,19 @@ class StandardPage(BasePage):
InlinePanel('authors', label="Authors"),
]

# Export fields over REST API
api_fields = [
APIField('introduction'),
APIField('body'),
APIField('featured_image', serializer=ImageRenditionField('fill-1920x1080')),
APIField('featured_image_caption'),
]

graphql_fields = [
GraphQLString("introduction"),
GraphQLStreamfield("body"),
GraphQLImage("featured_image"),
GraphQLString("featured_image_caption"),
]

class Meta:
Expand Down

0 comments on commit 39a04f1

Please sign in to comment.