Treelib: vyrábíme nové uzly... snad
This commit is contained in:
parent
78a667b42c
commit
62d6c0df02
1 changed files with 16 additions and 2 deletions
|
@ -153,11 +153,25 @@ def get_prev_node_of_type(node, type):
|
||||||
|
|
||||||
# Editace stromu:
|
# Editace stromu:
|
||||||
def create_node_after(predecessor, type, **kwargs):
|
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)
|
# Vyrábí prvního syna, ostatní nalepí za (existují-li)
|
||||||
def create_child(parent, type, **kwargs):
|
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):
|
def create_node_before(some, arguments, but, i, dont, know, which, yet):
|
||||||
pass
|
pass
|
||||||
|
|
Loading…
Reference in a new issue