Experiment with using wagtail api calls to serialize and deserialize StreamFields
This commit is contained in:
parent
f3a6c0bfe0
commit
ed4616bd24
|
|
@ -40,6 +40,9 @@ class GenericStreamFieldType(Scalar):
|
||||||
|
|
||||||
return stream_data
|
return stream_data
|
||||||
|
|
||||||
|
# by_api = stream_value.stream_block.get_api_representation(stream_value)
|
||||||
|
# return by_api
|
||||||
|
|
||||||
|
|
||||||
@convert_django_field.register(StreamField)
|
@convert_django_field.register(StreamField)
|
||||||
def convert_stream_field(field, registry=None):
|
def convert_stream_field(field, registry=None):
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ from wagtail.core import blocks
|
||||||
|
|
||||||
DEFAULT_RICH_TEXT_FEATURES = ['bold', 'italic', 'link', 'ol', 'ul']
|
DEFAULT_RICH_TEXT_FEATURES = ['bold', 'italic', 'link', 'ol', 'ul']
|
||||||
|
|
||||||
|
|
||||||
# link_block
|
# link_block
|
||||||
class LinkBlock(blocks.StructBlock):
|
class LinkBlock(blocks.StructBlock):
|
||||||
text = blocks.TextBlock()
|
text = blocks.TextBlock()
|
||||||
|
|
|
||||||
|
|
@ -94,6 +94,16 @@ class ContentBlockFactory(BasePageFactory):
|
||||||
'task': TextBlockFactory
|
'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
|
@classmethod
|
||||||
def stream_field_magic(cls, kwargs, stream_field_name):
|
def stream_field_magic(cls, kwargs, stream_field_name):
|
||||||
if stream_field_name in kwargs:
|
if stream_field_name in kwargs:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue