Skip to content

Commit

Permalink
Handle ListBlock nested in StrucBlock nested in ListBlock in StructBlock
Browse files Browse the repository at this point in the history
The ListBlock in StructBlock Rabbit Hole
  • Loading branch information
zerolab committed Apr 28, 2022
1 parent 2abcdcc commit b00a671
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions wagtail_localize/segments/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,23 @@ def handle_list_block(self, list_block, raw_value=None):
raw_value[0]
)
if has_block_format:
for block in list_block.bound_blocks:
for index, block in enumerate(list_block.bound_blocks):
# pass on the relevant sub-block raw value, should it be a ListBlock
try:
if isinstance(raw_value, list):
block_raw_value = raw_value[index]
elif isinstance(raw_value, dict):
block_raw_value = raw_value["value"][index]
else:
block_raw_value = None
except (IndexError, KeyError):
block_raw_value = None

segments.extend(
segment.wrap(block.id)
for segment in self.handle_block(block.block, block.value)
for segment in self.handle_block(
block.block, block.value, raw_value=block_raw_value
)
)
return segments

Expand Down

0 comments on commit b00a671

Please sign in to comment.