diff --git a/seminar/views/views_all.py b/seminar/views/views_all.py index 9bb5276e..2e9bd864 100644 --- a/seminar/views/views_all.py +++ b/seminar/views/views_all.py @@ -106,16 +106,20 @@ class TNLData(object): return out @classmethod - def filter_treenode(cls, treenode, predicate): - tnll = cls._filter_treenode_recursive(treenode, predicate) # TreeNodeList List :-) - # Teď vyrobíme virtuální TNL, který nemá obsah, ale má za potomky všecny nalezené TNLData + def from_tnldata_list(cls, tnllist): + """Vyrobíme virtuální TNL, který nemá obsah, ale má za potomky všechna zadaná TNLData""" result = cls(None) - for idx, tnl in enumerate(tnll): + for idx, tnl in enumerate(tnllist): result.children.append(tnl) tnl.parent = result tnl.index = idx return result + @classmethod + def filter_treenode(cls, treenode, predicate): + tnll = cls._filter_treenode_recursive(treenode, predicate) # TreeNodeList List :-) + return TNLData.from_tnldata_list(tnll) + @classmethod def _filter_treenode_recursive(cls, treenode, predicate): if predicate(treenode):