Skip to content

Commit 88fdf50

Browse files
committed
listblock, stream_data response
1 parent 6d3ccbb commit 88fdf50

File tree

4 files changed

+420
-5
lines changed

4 files changed

+420
-5
lines changed

books/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def get_book_data(book):
7474
'has_faculty_resources': has_faculty_resources,
7575
'has_student_resources': has_student_resources,
7676
'assignable_book': book.assignable_book,
77-
'promote_snippet': book.promote_snippet,
77+
'promote_snippet': book.promote_snippet.stream_block.get_api_representation(book.promote_snippet),
7878
'promote_tags': [snippet.value.name for snippet in book.promote_snippet],
7979
}
8080
except Exception as e:

pages/custom_blocks.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -326,13 +326,13 @@ def get_api_representation(self, value, context=None):
326326
'title': value['title'],
327327
}
328328

329-
class BookListBlock(blocks.StreamBlock):
329+
class BookListBlock(blocks.StructBlock):
330330
books = blocks.PageChooserBlock(page_type=['books.Book'], required=False)
331331

332332
class Meta:
333333
icon = 'placeholder'
334334
label = "Books"
335335

336336
def get_api_representation(self, value, context=None):
337-
# value is a StreamValue of blocks, each with .value as a Book page
338-
return [book_data for book in value if (book_data := get_book_data(book.value))]
337+
if value:
338+
return get_book_data(value['books'])

0 commit comments

Comments
 (0)