TreeLib: Fix type check

This commit is contained in:
Pavel 'LEdoian' Turinsky 2020-06-11 22:51:55 +00:00
parent b6f2b94a01
commit 15449ae24b

View file

@ -229,7 +229,7 @@ def create_node_after(predecessor, type, **kwargs):
from seminar.models import TreeNode
if predecessor is None:
raise TreeLibError("Nelze vyrábět sirotky! (predecessor=None)")
if not isinstance(type, TreeNode):
if not issubclass(type, TreeNode):
raise TreeLibError("Nový node není node!")
new_node = type.objects.create(**kwargs)
new_node.root = predecessor.root
@ -246,7 +246,7 @@ def create_child(parent, type, **kwargs):
from seminar.models import TreeNode
if parent is None:
raise TreeLibError("Nelze vyrábět sirotky! (parent=None)")
if not isinstance(type, TreeNode):
if not issubclass(type, TreeNode):
raise TreeLibError("Nový node není node!")
new_node = type.objects.create(**kwargs)
new_node.root = parent.root
@ -284,7 +284,7 @@ def create_node_before(successor, type, **kwargs):
from seminar.models import TreeNode
if successor is None:
raise TreeLibError("Nelze vyrábět sirotky! (successor=None)")
if not isinstance(type, TreeNode):
if not issubclass(type, TreeNode):
raise TreeLibError("Nový node není node!")
if safe_pred(successor) is not None:
# Easy: přidáme za předchůdce