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