Insert new content block at first position

This commit is contained in:
Ramon Wenger 2018-09-10 10:21:25 +02:00
parent d6b3fc09cb
commit ec03c03c48
1 changed files with 6 additions and 2 deletions

View File

@ -113,8 +113,12 @@ class AddContentBlock(relay.ClientIDMutation):
if parent is not None:
parent_chapter = get_object(Chapter, parent).specific
first_sibling = parent_chapter.get_first_child()
if first_sibling is not None:
first_sibling.add_sibling(instance=new_content_block, pos='left')
else:
parent_chapter.add_child(instance=new_content_block)
if after is not None:
elif after is not None:
sibling = get_object(ContentBlock, after).specific
sibling.add_sibling(instance=new_content_block, pos='right')