Fix bug in room contents
This commit is contained in:
parent
41bbfd7177
commit
dc8ec86610
|
|
@ -19,10 +19,7 @@ class GenericStreamFieldType(Scalar):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def serialize(stream_value):
|
def serialize(stream_value):
|
||||||
raw_data = stream_value.raw_data
|
raw_data = stream_value.raw_data
|
||||||
return augment_fields(raw_data)
|
return list(augment_fields(raw_data))
|
||||||
|
|
||||||
# by_api = stream_value.stream_block.get_api_representation(stream_value)
|
|
||||||
# return by_api
|
|
||||||
|
|
||||||
|
|
||||||
def augment_fields(raw_data):
|
def augment_fields(raw_data):
|
||||||
|
|
@ -94,4 +91,3 @@ def augment_fields(raw_data):
|
||||||
@convert_django_field.register(StreamField)
|
@convert_django_field.register(StreamField)
|
||||||
def convert_stream_field(field, registry=None):
|
def convert_stream_field(field, registry=None):
|
||||||
return GenericStreamFieldType(description=field.help_text, required=not field.null)
|
return GenericStreamFieldType(description=field.help_text, required=not field.null)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,6 @@ class ContentBlockNode(DjangoObjectType, HiddenAndVisibleForMixin):
|
||||||
|
|
||||||
def resolve_contents(self, info, **kwargs):
|
def resolve_contents(self, info, **kwargs):
|
||||||
updated_raw_data = []
|
updated_raw_data = []
|
||||||
# todo: deprecated as of wagtail 2.12 https://docs.wagtail.io/en/stable/releases/2.12.html
|
|
||||||
for content in self.contents.raw_data:
|
for content in self.contents.raw_data:
|
||||||
# only show solutions to teachers and students for whom their teachers have them enabled
|
# only show solutions to teachers and students for whom their teachers have them enabled
|
||||||
if is_solution_and_hidden_for_user(content['type'], info.context.user, self.module):
|
if is_solution_and_hidden_for_user(content['type'], info.context.user, self.module):
|
||||||
|
|
@ -71,7 +70,6 @@ class ContentBlockNode(DjangoObjectType, HiddenAndVisibleForMixin):
|
||||||
content = process_module_room_slug_block(content)
|
content = process_module_room_slug_block(content)
|
||||||
updated_raw_data.append(content)
|
updated_raw_data.append(content)
|
||||||
|
|
||||||
# todo: deprecated as of wagtail 2.12 https://docs.wagtail.io/en/stable/releases/2.12.html
|
|
||||||
self.contents.raw_data = updated_raw_data
|
self.contents.raw_data = updated_raw_data
|
||||||
return self.contents
|
return self.contents
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue