Experiment with using wagtail api calls to serialize and deserialize StreamFields

This commit is contained in:
Pawel Kowalski 2018-09-05 16:40:27 +02:00
parent f3a6c0bfe0
commit ed4616bd24
3 changed files with 14 additions and 0 deletions

View File

@ -40,6 +40,9 @@ class GenericStreamFieldType(Scalar):
return stream_data
# by_api = stream_value.stream_block.get_api_representation(stream_value)
# return by_api
@convert_django_field.register(StreamField)
def convert_stream_field(field, registry=None):

View File

@ -2,6 +2,7 @@ from wagtail.core import blocks
DEFAULT_RICH_TEXT_FEATURES = ['bold', 'italic', 'link', 'ol', 'ul']
# link_block
class LinkBlock(blocks.StructBlock):
text = blocks.TextBlock()

View File

@ -94,6 +94,16 @@ class ContentBlockFactory(BasePageFactory):
'task': TextBlockFactory
})
# maybe this is a better way to create a strem field
#
# contents = graphene.JSONString()
#
# contents_param = kwargs['contents']
# new_content_block = ContentBlock(type=type_param, title=title)
# what_is_this = new_content_block.contents.stream_block.to_python(contents_param)
# new_content_block.contents = what_is_this
@classmethod
def stream_field_magic(cls, kwargs, stream_field_name):
if stream_field_name in kwargs: