|
|
@ -159,51 +159,60 @@ class TreeNodePridatView(generic.View): |
|
|
|
} |
|
|
|
|
|
|
|
def post(self, request, *args, **kwargs): |
|
|
|
kam = self.kwargs['kam'] |
|
|
|
node = s.TreeNode.objects.get(pk=self.kwargs['pk']) |
|
|
|
kam = self.kwargs['kam'] |
|
|
|
|
|
|
|
if kam not in ('syn','za'): |
|
|
|
raise ValidationError('Přidat lze pouze před nebo za node') |
|
|
|
if kam == 'syn': |
|
|
|
strtyp = request.POST.get('pridat-typ-{}-syn'.format(node.id)) |
|
|
|
typ = self.type_from_str[strtyp] |
|
|
|
if typ == m.TextNode: |
|
|
|
text_obj = m.Text() |
|
|
|
text_obj.save() |
|
|
|
node = treelib.create_child(node,typ,text=text_obj) |
|
|
|
else: |
|
|
|
node = treelib.create_child(node,typ) |
|
|
|
if kam == 'za': |
|
|
|
strtyp = request.POST.get('pridat-typ-{}-za'.format(node.id)) |
|
|
|
typ = self.type_from_str[strtyp] |
|
|
|
if typ == m.TextNode: |
|
|
|
text_obj = m.Text() |
|
|
|
text_obj.save() |
|
|
|
node = treelib.create_node_after(node,typ,text=text_obj) |
|
|
|
else: |
|
|
|
node = treelib.create_node_after(node,typ) |
|
|
|
|
|
|
|
return redirect(node.get_admin_url()) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TreeNodeSmazatView(generic.base.View): |
|
|
|
def post(self, request, *args, **kwargs): |
|
|
|
pass |
|
|
|
pass |
|
|
|
node = s.TreeNode.objects.get(pk=self.kwargs['pk']) |
|
|
|
if node.first_child: |
|
|
|
raise NotImplemented('Mazání TreeNode se syny není zatím podporováno!') |
|
|
|
node.delete() |
|
|
|
|
|
|
|
class TreeNodeOdvesitView(generic.base.View): |
|
|
|
def post(self, request, *args, **kwargs): |
|
|
|
node = s.TreeNode.objects.get(pk=self.kwargs['pk']) |
|
|
|
pass |
|
|
|
pass |
|
|
|
|
|
|
|
class TreeNodePodvesitView(generic.base.View): |
|
|
|
def post(self, request, *args, **kwargs): |
|
|
|
pass |
|
|
|
pass |
|
|
|
node = s.TreeNode.objects.get(pk=self.kwargs['pk']) |
|
|
|
kam = self.kwargs['kam'] |
|
|
|
if kam == 'pred': |
|
|
|
lower_node(node) |
|
|
|
elif kam == 'za': |
|
|
|
raise NotImplemented('Podvěsit za není zatím podporováno') |
|
|
|
|
|
|
|
class TreeNodeProhoditView(generic.base.View): |
|
|
|
def post(self, request, *args, **kwargs): |
|
|
|
pass |
|
|
|
pass |
|
|
|
node = s.TreeNode.objects.get(pk=self.kwargs['pk']) |
|
|
|
treelib.swap_succ(node) |
|
|
|
#FIXME ve formulari predat puvodni url a vratit redirect na ni |
|
|
|
|
|
|
|
|
|
|
|
class ProblemView(generic.DetailView): |
|
|
|