diff --git a/seminar/treelib.py b/seminar/treelib.py index 6e531c63..0f21454c 100644 --- a/seminar/treelib.py +++ b/seminar/treelib.py @@ -153,11 +153,25 @@ def get_prev_node_of_type(node, type): # Editace stromu: def create_node_after(predecessor, type, **kwargs): - pass + new_node = type.objects.create(**kwargs) + new_node.save() + succ = predecessor.succ + predecessor.succ = new_node + predecessor.save() + new_node.succ = succ + new_node.save() # Vyrábí prvního syna, ostatní nalepí za (existují-li) def create_child(parent, type, **kwargs): - pass + new_node = type.objects.create(**kwargs) + new_node.save() + orig_child = parent.first_child + parent.first_child = new_node + parent.save() + if orig_child is not None: + # Přidáme původního prvního syna jako potomka nového vrcholu + new_node.succ = orig_child + new_node.save() def create_node_before(some, arguments, but, i, dont, know, which, yet): pass