From 62d6c0df02130a0102d8da72d6a347a548f8b11b Mon Sep 17 00:00:00 2001 From: Pavel 'LEdoian' Turinsky Date: Thu, 19 Mar 2020 00:22:18 +0100 Subject: [PATCH] =?UTF-8?q?Treelib:=20vyr=C3=A1b=C3=ADme=20nov=C3=A9=20uzl?= =?UTF-8?q?y...=20snad?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- seminar/treelib.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) 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