Browse Source

Merge branch 'treenode_editor' of gimli.ms.mff.cuni.cz:/akce/mam/git/mamweb into treenode_editor

export_seznamu_prednasek
parent
commit
df1ca9a266
  1. 24
      seminar/views/views_all.py

24
seminar/views/views_all.py

@ -103,8 +103,30 @@ class TNLData(object):
outitem = cls.from_treenode(ch,out,idx)
out.children.append(outitem)
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
result = cls(None)
for idx, tnl in enumerate(tnll):
result.children.append(tnl)
tnl.parent = result
tnl.index = idx
return result
@classmethod
def _filter_treenode_recursive(cls, treenode, predicate):
if predicate(treenode):
return [cls.from_treenode(treenode)]
else:
found = []
for tn in all_children(treenode):
result = cls.filter_treenode(tn, predicate)
# Result by v tuhle chvíli měl být seznam TNLDat odpovídající treenodům, jež matchnuly predikát.
for tnl in result:
found.append(tnl)
return found
class TreeNodeView(generic.DetailView):
model = s.TreeNode

Loading…
Cancel
Save